@fastly/compute-js-static-publish 5.2.1 → 6.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build-static.ts"],"names":[],"mappings":"AA+DA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AA6IhD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAqe5F"}
1
+ {"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build-static.ts"],"names":[],"mappings":"AA+DA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AA6IhD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAye5F"}
@@ -264,9 +264,12 @@ export async function buildStaticLoader(commandLineValues) {
264
264
  console.log(`⚠️ Notice: By default, pre-compressed content assets are not generated when KV Store is not used.`);
265
265
  console.log(" If you want to pre-compress assets, add a value for 'contentCompression' to your static-publish.rc.js.");
266
266
  }
267
+ // The Static Content Root Dir, which will hold the loaders and a copy of static files.
268
+ const staticContentRootDir = config.staticContentRootDir;
267
269
  // Create "static content" dir that will be used to hold a copy of static files.
268
- // NOTE: this is needed because includeBytes doesn't seem to be able to traverse up to parent dir of the Compute project.
269
- const staticContentDir = './src/static-content';
270
+ // NOTE: This copy is created so that they can be loaded with includeBytes(), which requires
271
+ // all files to be under the Compute project dir.
272
+ const staticContentDir = staticContentRootDir + '/static-content';
270
273
  fs.rmSync(staticContentDir, { recursive: true, force: true });
271
274
  fs.mkdirSync(staticContentDir, { recursive: true });
272
275
  // Build content assets metadata
@@ -396,12 +399,12 @@ export async function buildStaticLoader(commandLineValues) {
396
399
  metadataFileContents += ` ${JSON.stringify(key)}: ${JSON.stringify(value)},\n`;
397
400
  }
398
401
  metadataFileContents += '};\n';
399
- fs.writeFileSync('./src/statics-metadata.js', metadataFileContents);
402
+ fs.writeFileSync(staticContentRootDir + '/statics-metadata.js', metadataFileContents);
400
403
  console.log(`✅ Wrote static file metadata for ${contentItems} file(s).`);
401
404
  // Copy Types file for static file loader
402
405
  try {
403
406
  const typesFile = path.resolve(__dirname, '../../../resources/statics-metadata.d.ts');
404
- fs.copyFileSync(typesFile, './src/statics-metadata.d.ts');
407
+ fs.copyFileSync(typesFile, staticContentRootDir + '/statics-metadata.d.ts');
405
408
  console.log("✅ Wrote content assets metadata types file statics-metadata.d.ts.");
406
409
  }
407
410
  catch {
@@ -423,9 +426,9 @@ export async function buildStaticLoader(commandLineValues) {
423
426
  if (assetInfo.includeModule && assetInfo.useStaticImport) {
424
427
  staticImportModuleNumber++;
425
428
  staticImportModuleNumbers[assetInfo.assetKey] = staticImportModuleNumber;
426
- // static-content lives in the src dir, so the import must be declared as
429
+ // static-content lives in the staticContentRootDir dir, so the import must be declared as
427
430
  // relative to that file.
428
- const relativeFilePath = path.relative('./src', assetInfo.file);
431
+ const relativeFilePath = path.relative(staticContentRootDir, assetInfo.file);
429
432
  fileContents += `import * as fileModule${staticImportModuleNumber} from "${relativeFilePath}";\n`;
430
433
  }
431
434
  }
@@ -445,9 +448,9 @@ export async function buildStaticLoader(commandLineValues) {
445
448
  module = `fileModule${moduleNumber}`;
446
449
  }
447
450
  else {
448
- // static-content lives in the src dir, so the import must be declared as
451
+ // static-content lives in the staticContentRootDir dir, so the import must be declared as
449
452
  // relative to that file.
450
- const relativeFilePath = path.relative('./src', assetInfo.file);
453
+ const relativeFilePath = path.relative(staticContentRootDir, assetInfo.file);
451
454
  loadModuleFunction = `() => import("${relativeFilePath}")`;
452
455
  module = 'null';
453
456
  }
@@ -520,15 +523,15 @@ export async function buildStaticLoader(commandLineValues) {
520
523
  '\n }' +
521
524
  '\n return server;' +
522
525
  '\n}\n';
523
- fs.writeFileSync('./src/statics.js', fileContents);
526
+ fs.writeFileSync(staticContentRootDir + '/statics.js', fileContents);
524
527
  console.log("✅ Wrote static file loader for " + files.length + " file(s).");
525
528
  // Copy Types file for static file loader
526
529
  try {
527
530
  const staticsTypeFile = path.resolve(__dirname, '../../../resources/statics.d.ts');
528
- fs.copyFileSync(staticsTypeFile, './src/statics.d.ts');
529
- console.log("✅ Wrote static file loader types file statics.d.ts.");
531
+ fs.copyFileSync(staticsTypeFile, staticContentRootDir + '/statics.d.ts');
532
+ console.log(`✅ Wrote static file loader types file ${staticContentRootDir}/statics.d.ts.`);
530
533
  }
531
534
  catch {
532
- console.log("⚠️ Notice: could not write static file loader types file statics.d.ts.");
535
+ console.log(`⚠️ Notice: could not write static file loader types file ${staticContentRootDir}/statics.d.ts.`);
533
536
  }
534
537
  }
@@ -1 +1 @@
1
- {"version":3,"file":"init-app.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAoPvD,wBAAgB,OAAO,CAAC,iBAAiB,EAAE,kBAAkB,QAka5D"}
1
+ {"version":3,"file":"init-app.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAiQvD,wBAAgB,OAAO,CAAC,iBAAiB,EAAE,kBAAkB,QA6c5D"}
@@ -11,6 +11,7 @@ const defaultOptions = {
11
11
  rootDir: undefined,
12
12
  publicDir: undefined,
13
13
  staticDirs: [],
14
+ staticContentRootDir: undefined,
14
15
  spa: undefined,
15
16
  notFoundPage: '[public-dir]/404.html',
16
17
  autoIndex: ['index.html', 'index.htm'],
@@ -67,6 +68,16 @@ function processCommandLineArgs(commandLineValues) {
67
68
  staticDirs = asArray.map(x => path.resolve(x));
68
69
  }
69
70
  }
71
+ let staticContentRootDir;
72
+ {
73
+ const staticContentRootDirValue = commandLineValues['static-content-root-dir'];
74
+ if (staticContentRootDirValue == null || typeof staticContentRootDirValue === 'string') {
75
+ staticContentRootDir = staticContentRootDirValue;
76
+ }
77
+ if (staticContentRootDir != null) {
78
+ staticContentRootDir = path.resolve(staticContentRootDir);
79
+ }
80
+ }
70
81
  let spa;
71
82
  {
72
83
  const spaValue = commandLineValues['spa'];
@@ -167,6 +178,7 @@ function processCommandLineArgs(commandLineValues) {
167
178
  rootDir,
168
179
  publicDir,
169
180
  staticDirs,
181
+ staticContentRootDir,
170
182
  spa,
171
183
  notFoundPage,
172
184
  autoIndex,
@@ -254,7 +266,7 @@ export function initApp(commandLineValues) {
254
266
  ...options,
255
267
  ...(preset != null ? preset.defaultOptions : {}),
256
268
  ...pickKeys(['author', 'name', 'description'], (packageJson ?? {})),
257
- ...pickKeys(['rootDir', 'publicDir', 'staticDirs', 'spa', 'notFoundPage', 'autoIndex', 'autoExt', 'author', 'name', 'description', 'serviceId', 'kvStoreName'], commandLineAppOptions),
269
+ ...pickKeys(['rootDir', 'publicDir', 'staticDirs', 'staticContentRootDir', 'spa', 'notFoundPage', 'autoIndex', 'autoExt', 'author', 'name', 'description', 'serviceId', 'kvStoreName'], commandLineAppOptions),
258
270
  };
259
271
  if (preset != null) {
260
272
  if (!preset.check(packageJson, options)) {
@@ -315,6 +327,22 @@ export function initApp(commandLineValues) {
315
327
  }
316
328
  staticDirs.push(staticDir);
317
329
  }
330
+ // Static Content Root Dir must be under the current dir
331
+ let staticContentRootDir = options.staticContentRootDir;
332
+ if (staticContentRootDir == null) {
333
+ staticContentRootDir = path.resolve('./static-publisher');
334
+ }
335
+ if (staticContentRootDir.includes('//') ||
336
+ !staticContentRootDir.startsWith(process.cwd())) {
337
+ console.error(`❌ Specified static content root directory '${staticContentRootDir}' must be a relative path.`);
338
+ console.error(` * ${publicDir} must be under ${rootDir}`);
339
+ process.exitCode = 1;
340
+ return;
341
+ }
342
+ while (staticContentRootDir.endsWith('/')) {
343
+ staticContentRootDir = staticContentRootDir.slice(0, -1);
344
+ }
345
+ staticContentRootDir = path.relative(process.cwd(), staticContentRootDir);
318
346
  // SPA and Not Found are relative to the asset root dir.
319
347
  const SPA = options.spa;
320
348
  let spaFilename;
@@ -374,18 +402,19 @@ export function initApp(commandLineValues) {
374
402
  return v.startsWith('..') ? v : './' + v;
375
403
  }
376
404
  console.log('');
377
- console.log('Asset Root Dir :', rootRelative(rootDir));
378
- console.log('Public Dir :', rootRelative(publicDir));
379
- console.log('Static Dir :', staticDirs.length > 0 ? staticDirs.map(rootRelative) : '(None)');
380
- console.log('SPA :', rootRelative(spaFilename) ?? '(None)');
381
- console.log('404 Page :', rootRelative(notFoundPageFilename) ?? '(None)');
382
- console.log('Auto-Index :', autoIndex.length > 0 ? autoIndex.map(rootRelative) : '(None)');
383
- console.log('Auto-Ext :', autoExt.length > 0 ? autoExt.map(rootRelative) : '(None)');
384
- console.log('name :', name);
385
- console.log('author :', author);
386
- console.log('description :', description);
387
- console.log('Service ID :', fastlyServiceId ?? '(None)');
388
- console.log('KV Store Name :', kvStoreName ?? '(None)');
405
+ console.log('Asset Root Dir :', rootRelative(rootDir));
406
+ console.log('Public Dir :', rootRelative(publicDir));
407
+ console.log('Static Dir :', staticDirs.length > 0 ? staticDirs.map(rootRelative) : '(None)');
408
+ console.log('Static Content Root Dir :', staticContentRootDir);
409
+ console.log('SPA :', rootRelative(spaFilename) ?? '(None)');
410
+ console.log('404 Page :', rootRelative(notFoundPageFilename) ?? '(None)');
411
+ console.log('Auto-Index :', autoIndex.length > 0 ? autoIndex.map(rootRelative) : '(None)');
412
+ console.log('Auto-Ext :', autoExt.length > 0 ? autoExt.map(rootRelative) : '(None)');
413
+ console.log('name :', name);
414
+ console.log('author :', author);
415
+ console.log('description :', description);
416
+ console.log('Service ID :', fastlyServiceId ?? '(None)');
417
+ console.log('KV Store Name :', kvStoreName ?? '(None)');
389
418
  console.log('');
390
419
  if (useWebpack) {
391
420
  console.log('Creating project with Webpack.');
@@ -394,16 +423,17 @@ export function initApp(commandLineValues) {
394
423
  console.log("Initializing Compute Application in " + computeJsDir + "...");
395
424
  fs.mkdirSync(computeJsDir);
396
425
  fs.mkdirSync(path.resolve(computeJsDir, './src'));
426
+ const staticContentRootDirFromRoot = staticContentRootDir.slice(1);
397
427
  // .gitignore
398
428
  const gitIgnoreContent = `\
399
429
  /node_modules
400
430
  /bin
401
431
  /pkg
402
- /src/statics.js
403
- /src/statics.d.ts
404
- /src/statics-metadata.js
405
- /src/statics-metadata.d.ts
406
- /src/static-content
432
+ ${staticContentRootDirFromRoot}/statics.js
433
+ ${staticContentRootDirFromRoot}/statics.d.ts
434
+ ${staticContentRootDirFromRoot}/statics-metadata.js
435
+ ${staticContentRootDirFromRoot}/statics-metadata.d.ts
436
+ ${staticContentRootDirFromRoot}/static-content
407
437
  `;
408
438
  const gitIgnorePath = path.resolve(computeJsDir, '.gitignore');
409
439
  fs.writeFileSync(gitIgnorePath, gitIgnoreContent, "utf-8");
@@ -514,6 +544,7 @@ ${fastlyServiceId != null ? `service_id = "${fastlyServiceId}"
514
544
  /** @type {import('@fastly/compute-js-static-publish').StaticPublisherConfig} */
515
545
  const config = {
516
546
  rootDir: ${JSON.stringify(rootDirRel)},
547
+ staticContentRootDir: ${JSON.stringify(staticContentRootDir)},
517
548
  ${(kvStoreName != null ? 'kvStoreName: ' + JSON.stringify(kvStoreName) : '// kvStoreName: false')},
518
549
  // excludeDirs: [ './node_modules' ],
519
550
  // excludeDotFiles: true,
@@ -547,9 +578,29 @@ ${useWebpack ? 'module.exports =' : 'export default'} config;
547
578
  fs.copyFileSync(webpackConfigJsSrcPath, webpackConfigJsPath);
548
579
  }
549
580
  // src/index.js
550
- const indexJsSrcPath = path.resolve(__dirname, '../../../resources/index.js');
581
+ const staticsRelativePath = path.relative('./src', staticContentRootDir);
582
+ const indexJsContent = /* language=JavaScript */ `\
583
+ /// <reference types="@fastly/js-compute" />
584
+ import { getServer } from '${staticsRelativePath}/statics.js';
585
+ const staticContentServer = getServer();
586
+
587
+ // eslint-disable-next-line no-restricted-globals
588
+ addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
589
+ async function handleRequest(event) {
590
+
591
+ const response = await staticContentServer.serveRequest(event.request);
592
+ if (response != null) {
593
+ return response;
594
+ }
595
+
596
+ // Do custom things here!
597
+ // Handle API requests, serve non-static responses, etc.
598
+
599
+ return new Response('Not found', { status: 404 });
600
+ }
601
+ `;
551
602
  const indexJsPath = path.resolve(computeJsDir, './src/index.js');
552
- fs.copyFileSync(indexJsSrcPath, indexJsPath);
603
+ fs.writeFileSync(indexJsPath, indexJsContent, 'utf-8');
553
604
  console.log("🚀 Compute application created!");
554
605
  console.log('Installing dependencies...');
555
606
  console.log(`npm --prefix ${COMPUTE_JS_DIR} install`);
@@ -33,6 +33,9 @@ const optionDefinitions = [
33
33
  // with a long TTL. Each entry should be a relative path
34
34
  // from 'public-dir'.
35
35
  { name: 'static-dir', type: String, multiple: true, },
36
+ // The 'static content root directory' where the Static Publisher
37
+ // outputs its metadata files and loaders.
38
+ { name: 'static-content-root-dir', type: String, },
36
39
  // Path to a file to be used to serve in a SPA application.
37
40
  // The Publisher Server will serve this file with a 200 status code
38
41
  // when the request doesn't match a known file, and the accept
@@ -1 +1 @@
1
- {"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/cli/load-config.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,+BAA+B,EAEhC,MAAM,+BAA+B,CAAC;AAyVvC,wBAAsB,cAAc,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,+BAA+B,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAAC,CAiBnI"}
1
+ {"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/cli/load-config.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,+BAA+B,EAEhC,MAAM,+BAA+B,CAAC;AA6WvC,wBAAsB,cAAc,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,+BAA+B,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAAC,CAiBnI"}
@@ -172,7 +172,7 @@ const normalizePublisherServerConfig = buildNormalizeFunctionForObject((config,
172
172
  };
173
173
  });
174
174
  const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
175
- let { rootDir, kvStoreName, excludeDirs, excludeDotFiles, includeWellKnown, contentAssetInclusionTest, contentCompression, moduleAssetInclusionTest, contentTypes, server, } = config;
175
+ let { rootDir, staticContentRootDir, kvStoreName, excludeDirs, excludeDotFiles, includeWellKnown, contentAssetInclusionTest, contentCompression, moduleAssetInclusionTest, contentTypes, server, } = config;
176
176
  if (!isSpecified(config, 'rootDir')) {
177
177
  errors.push('rootDir must be specified.');
178
178
  }
@@ -184,6 +184,22 @@ const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
184
184
  errors.push('rootDir must be a non-empty string.');
185
185
  }
186
186
  }
187
+ if (!isSpecified(config, 'staticContentRootDir')) {
188
+ staticContentRootDir = './src';
189
+ }
190
+ else {
191
+ if (staticContentRootDir.startsWith('./') &&
192
+ staticContentRootDir !== './' &&
193
+ !staticContentRootDir.includes('//')) {
194
+ // ok
195
+ }
196
+ else {
197
+ errors.push('staticContentRootDir must be a relative subdirectory.');
198
+ }
199
+ while (staticContentRootDir.endsWith('/')) {
200
+ staticContentRootDir = staticContentRootDir.slice(0, -1);
201
+ }
202
+ }
187
203
  if (!isSpecified(config, 'kvStoreName')) {
188
204
  kvStoreName = null;
189
205
  }
@@ -335,6 +351,7 @@ const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
335
351
  }
336
352
  return {
337
353
  rootDir,
354
+ staticContentRootDir,
338
355
  kvStoreName,
339
356
  excludeDotFiles,
340
357
  includeWellKnown,
@@ -2,6 +2,7 @@ export type AppOptions = {
2
2
  rootDir: string | undefined;
3
3
  publicDir: string | undefined;
4
4
  staticDirs: string[];
5
+ staticContentRootDir: string | undefined;
5
6
  spa: string | undefined;
6
7
  notFoundPage: string | undefined;
7
8
  autoIndex: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
1
+ {"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
@@ -11,6 +11,7 @@ export type ModuleAssetInclusionResultNormalized = {
11
11
  };
12
12
  export type StaticPublisherConfigNormalized = {
13
13
  rootDir: string;
14
+ staticContentRootDir: string;
14
15
  kvStoreName: string | null;
15
16
  excludeDirs: ExcludeDirTest[];
16
17
  excludeDotFiles: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config-normalized.d.ts","sourceRoot":"","sources":["../../src/types/config-normalized.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,MAAM,MAAM,qCAAqC,GAAG;IAClD,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,E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,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC5D,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;IAC9C,wBAAwB,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC1D,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,MAAM,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACvC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CAErB,CAAC"}
@@ -14,6 +14,7 @@ export type ModuleAssetInclusionResult = {
14
14
  export type ModuleAssetInclusionTest = (assetKey: string, contentType?: string) => ModuleAssetInclusionResult | true | false | 'static-import' | null;
15
15
  export type StaticPublisherConfig = {
16
16
  rootDir: string;
17
+ staticContentRootDir: string;
17
18
  kvStoreName?: string | false | null;
18
19
  excludeDirs?: (string | ExcludeDirTest)[] | string | ExcludeDirTest | null;
19
20
  excludeDotFiles?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG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
+ "version": "6.0.0-beta.0",
5
5
  "description": "Static Publisher for Fastly Compute JavaScript",
6
6
  "main": "./build/index.js",
7
7
  "types": "./build/index.d.ts",
@@ -1,18 +0,0 @@
1
- /// <reference types="@fastly/js-compute" />
2
- import { getServer } from './statics.js';
3
- const staticContentServer = getServer();
4
-
5
- // eslint-disable-next-line no-restricted-globals
6
- addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
7
- async function handleRequest(event) {
8
-
9
- const response = await staticContentServer.serveRequest(event.request);
10
- if (response != null) {
11
- return response;
12
- }
13
-
14
- // Do custom things here!
15
- // Handle API requests, serve non-static responses, etc.
16
-
17
- return new Response('Not found', { status: 404 });
18
- }