@lwrjs/core 0.9.0-alpha.26 → 0.9.0-alpha.28

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.
@@ -29,6 +29,7 @@ __export(exports, {
29
29
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
30
30
  function createProviderContext(serverContext) {
31
31
  const {
32
+ assets,
32
33
  cacheDir,
33
34
  lwc: {modules = []},
34
35
  routes,
@@ -64,6 +65,7 @@ function createProviderContext(serverContext) {
64
65
  viewRegistry: serverContext.viewRegistry.getPublicApi(),
65
66
  assetRegistry: serverContext.assetRegistry.getPublicApi(),
66
67
  config: (0, import_shared_utils.deepFreeze)({
68
+ assets,
67
69
  cacheDir,
68
70
  modules,
69
71
  routes,
@@ -36,10 +36,19 @@ function createAssetMiddleware(context) {
36
36
  } = context;
37
37
  return async (req, res) => {
38
38
  const {runtimeEnvironment} = req.getRuntimeContext(context.runtimeEnvironment);
39
- const {assetId, signature} = (0, import_identity.getAssetIdentity)(req);
39
+ const {assetId, immutable, signature} = (0, import_identity.getAssetIdentity)(req);
40
40
  if (basePath && !assetId.specifier.startsWith(basePath)) {
41
41
  assetId.specifier = import_path.default.join(basePath, assetId.specifier);
42
42
  }
43
+ const assetUri = await assetRegistry.resolveAssetUri(assetId, runtimeEnvironment);
44
+ if (assetUri.external) {
45
+ res.set({
46
+ Location: assetUri.uri,
47
+ "cache-control": "public, max-age=60"
48
+ });
49
+ res.sendStatus(302);
50
+ return;
51
+ }
43
52
  const asset = await assetRegistry.getAsset({...assetId, signature}, runtimeEnvironment, req.isSiteGeneration());
44
53
  if (req.isSiteGeneration()) {
45
54
  res.setSiteGenerationMetadata({asset});
@@ -47,6 +56,11 @@ function createAssetMiddleware(context) {
47
56
  if (asset.mime) {
48
57
  res.type(asset.mime);
49
58
  }
59
+ if (runtimeEnvironment.immutableAssets && immutable) {
60
+ res.setHeader("Cache-control", "public, max-age=12895706, immutable");
61
+ } else if (runtimeEnvironment.immutableAssets) {
62
+ res.setHeader("Cache-control", "public, max-age=60");
63
+ }
50
64
  res.status(200).stream(asset.stream());
51
65
  };
52
66
  }
@@ -76,14 +76,13 @@ function getResourceIdentity(req) {
76
76
  function getAssetIdentity(req) {
77
77
  const {signature, immutable, assetType: type} = req.params;
78
78
  const specifier = signature && type ? "/" + req.params[0] : req.originalUrl.split("?")[0];
79
- if (immutable) {
80
- }
81
79
  if (validateSpecifier(specifier) === false) {
82
80
  throw (0, import_diagnostics.createSingleDiagnosticError)({
83
81
  description: import_diagnostics.descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier)
84
82
  }, import_diagnostics.LwrUnresolvableError);
85
83
  }
86
84
  return {
85
+ immutable,
87
86
  assetId: {
88
87
  specifier,
89
88
  type
@@ -57,7 +57,7 @@ var SiteGenerator = class {
57
57
  const runtimeEnvironment = (0, import_config.getRuntimeEnvironment)(config);
58
58
  await this.generateRoutes(runtimeEnvironment, staticSiteGenerator, routes, basePath, dispatcher, outputDir, urlRewriteMap);
59
59
  this.writeNetlifyRedirectConfig(outputDir, urlRewriteMap);
60
- this.copyAssets(assets, outputDir, basePath);
60
+ await this.copyAssets(assets, outputDir, config);
61
61
  const endTime = import_perf_hooks.performance.now();
62
62
  const timeDiff = (endTime - startTime) / 1e3;
63
63
  import_shared_utils.logger.info(`[SSG] Static Site Generation complete in ${Math.round(timeDiff)} seconds`);
@@ -215,20 +215,24 @@ var SiteGenerator = class {
215
215
  mimeType: String(assetDefinition.mime)
216
216
  };
217
217
  const siteAssets = siteConfig.siteMetadata.getSiteAssets();
218
- siteAssets.assets[specifier] = resourceMetadata;
218
+ if (!siteAssets.assets[specifier]) {
219
+ siteAssets.assets[specifier] = resourceMetadata;
220
+ } else {
221
+ import_shared_utils.logger.debug(`[SSG] Ignore asset redefinition ${specifier}`);
222
+ }
219
223
  }
220
224
  }
221
225
  }
222
226
  async handleMappingResource(url, context, siteConfig, dispatcher) {
223
- const {importMetadata: importMetatdata} = siteConfig;
227
+ const {importMetadata} = siteConfig;
224
228
  const statusCode = context.response?.status;
225
229
  if (statusCode === 200) {
226
230
  const newImportMetadata = context.fs?.body;
227
231
  let filteredImportMetadata;
228
- if (!importMetatdata) {
232
+ if (!importMetadata) {
229
233
  filteredImportMetadata = newImportMetadata;
230
234
  } else {
231
- filteredImportMetadata = importMetatdata.addAdditionalMetadata(newImportMetadata);
235
+ filteredImportMetadata = importMetadata.addAdditionalMetadata(newImportMetadata);
232
236
  }
233
237
  const dispatchRequests = [];
234
238
  for (const uri of Object.keys(filteredImportMetadata.imports)) {
@@ -380,20 +384,65 @@ var SiteGenerator = class {
380
384
  });
381
385
  import_fs_extra.default.writeFileSync(serveJsonPath, JSON.stringify({rewrites, directoryListing: false, renderSingle: true}, null, 1));
382
386
  }
383
- copyAssets(assets, outputDir, basePath) {
387
+ async copyAssets(assets, outputDir, config) {
388
+ const {basePath} = config;
389
+ const runtimeEnvironment = (0, import_config.getRuntimeEnvironment)(config);
390
+ const siteConfig = this.createSiteConfig(outputDir, "en-US", new Map(), true, runtimeEnvironment);
384
391
  for (const asset of assets) {
385
392
  try {
386
- const assetSrcDir = asset.dir || asset.file;
387
- const assetOutputDir = (0, import_path.join)(outputDir, basePath ? basePath + asset.urlPath : asset.urlPath);
393
+ const assetSrcFile = asset.file;
394
+ const assetSrcDir = asset.dir;
395
+ const assetsPath = (0, import_path.join)(outputDir, basePath ? basePath + asset.urlPath : asset.urlPath);
388
396
  if (assetSrcDir && import_fs_extra.default.existsSync(assetSrcDir)) {
389
- import_fs_extra.default.copySync(assetSrcDir, assetOutputDir);
397
+ import_fs_extra.default.copySync(assetSrcDir, assetsPath);
398
+ this.addAssetsToMetadata(assetsPath, siteConfig);
399
+ } else if (assetSrcFile && import_fs_extra.default.existsSync(assetSrcFile)) {
400
+ import_fs_extra.default.copySync(assetSrcFile, assetsPath);
401
+ this.addAssetToMetadata(assetsPath, siteConfig);
390
402
  } else {
391
- import_shared_utils.logger.warn("[SSG] Could not find assets to copy at path: " + assetSrcDir);
403
+ import_shared_utils.logger.warn("[SSG] Could not find assets to copy at path: " + assetsPath);
392
404
  }
393
405
  } catch (e) {
394
406
  import_shared_utils.logger.error("[SSG] Error occurred processing asset config: " + JSON.stringify(asset), e);
395
407
  }
396
408
  }
409
+ await siteConfig.siteMetadata?.persistSiteMetadata();
410
+ }
411
+ addAssetsToMetadata(directoryPath, siteConfig) {
412
+ try {
413
+ const files = import_fs_extra.default.readdirSync(directoryPath);
414
+ for (const file of files) {
415
+ const filePath = (0, import_path.join)(directoryPath, file);
416
+ if (import_fs_extra.default.statSync(filePath).isDirectory()) {
417
+ this.addAssetsToMetadata(filePath, siteConfig);
418
+ } else {
419
+ this.addAssetToMetadata(filePath, siteConfig);
420
+ }
421
+ }
422
+ } catch (err) {
423
+ import_shared_utils.logger.warn(`[SSG] Unexpected error collecting asset directory metadata for ${directoryPath}`, err);
424
+ }
425
+ }
426
+ addAssetToMetadata(filePath, siteConfig) {
427
+ try {
428
+ const uri = encodeURI((0, import_path.normalize)(filePath).replace(siteConfig.outputDir, ""));
429
+ this.addAssetToSiteMetadata({
430
+ uri,
431
+ type: "asset",
432
+ stream: function(encoding) {
433
+ throw new Error("Function not implemented.");
434
+ },
435
+ entry: filePath,
436
+ ext: (0, import_path.extname)(filePath),
437
+ mime: (0, import_shared_utils.mimeLookup)(filePath),
438
+ ownHash: "not-provided",
439
+ content: function(encoding) {
440
+ throw new Error("Function not implemented.");
441
+ }
442
+ }, uri, siteConfig);
443
+ } catch (err) {
444
+ import_shared_utils.logger.warn(`[SSG] Unexpected error collecting asset metadata for ${filePath}`, err);
445
+ }
397
446
  }
398
447
  createSiteConfig(outputDir, locale, urlRewriteMap, skipBaseDocumentGeneration, runtimeEnvironment) {
399
448
  const featureFlags = this.filterFeatureFlags();
@@ -418,13 +467,13 @@ var SiteGenerator = class {
418
467
  filterFeatureFlags() {
419
468
  const ffs = (0, import_shared_utils.getFeatureFlags)();
420
469
  if (ffs && Object.keys(ffs).length) {
421
- const accumlator = {};
470
+ const accumulator = {};
422
471
  for (const [key, value] of Object.entries(ffs)) {
423
472
  if (value) {
424
- accumlator[key] = true;
473
+ accumulator[key] = true;
425
474
  }
426
475
  }
427
- return {featureFlags: accumlator};
476
+ return {featureFlags: accumulator};
428
477
  } else {
429
478
  return void 0;
430
479
  }
@@ -492,10 +541,10 @@ var ViewImportMetadataImpl = class {
492
541
  index
493
542
  };
494
543
  }
495
- mergeImportMetadata(targetImportMetdadata, newImportMetadata) {
496
- Object.assign(targetImportMetdadata.imports, newImportMetadata.imports);
497
- if (targetImportMetdadata.index) {
498
- Object.assign(targetImportMetdadata.index, newImportMetadata.index || {});
544
+ mergeImportMetadata(targetImportMetadata, newImportMetadata) {
545
+ Object.assign(targetImportMetadata.imports, newImportMetadata.imports);
546
+ if (targetImportMetadata.index) {
547
+ Object.assign(targetImportMetadata.index, newImportMetadata.index || {});
499
548
  }
500
549
  }
501
550
  };
@@ -1,7 +1,7 @@
1
1
  import { deepFreeze } from '@lwrjs/shared-utils';
2
2
  export function createProviderContext(serverContext) {
3
3
  // This is a subset of config to user-land code
4
- const { cacheDir, lwc: { modules = [] }, routes, errorRoutes, rootDir, contentDir, layoutsDir, locker, amdLoader, esmLoader, environment, basePath, bundleConfig, } = serverContext.appConfig;
4
+ const { assets, cacheDir, lwc: { modules = [] }, routes, errorRoutes, rootDir, contentDir, layoutsDir, locker, amdLoader, esmLoader, environment, basePath, bundleConfig, } = serverContext.appConfig;
5
5
  const { onModuleDefinitionChange, onModuleSourceChange } = serverContext.appObserver;
6
6
  const { notifyModuleDefinitionChanged, notifyModuleSourceChanged, notifyViewSourceChanged, notifyAssetSourceChanged, } = serverContext.appEmitter;
7
7
  return {
@@ -18,6 +18,7 @@ export function createProviderContext(serverContext) {
18
18
  viewRegistry: serverContext.viewRegistry.getPublicApi(),
19
19
  assetRegistry: serverContext.assetRegistry.getPublicApi(),
20
20
  config: deepFreeze({
21
+ assets,
21
22
  cacheDir,
22
23
  modules,
23
24
  routes,
@@ -5,10 +5,20 @@ function createAssetMiddleware(context) {
5
5
  const { assetRegistry, runtimeEnvironment: { basePath }, } = context;
6
6
  return async (req, res) => {
7
7
  const { runtimeEnvironment } = req.getRuntimeContext(context.runtimeEnvironment);
8
- const { assetId, signature } = getAssetIdentity(req);
8
+ const { assetId, immutable, signature } = getAssetIdentity(req);
9
9
  if (basePath && !assetId.specifier.startsWith(basePath)) {
10
10
  assetId.specifier = path.join(basePath, assetId.specifier);
11
11
  }
12
+ // Redirect if this is an external asset
13
+ const assetUri = await assetRegistry.resolveAssetUri(assetId, runtimeEnvironment);
14
+ if (assetUri.external) {
15
+ res.set({
16
+ Location: assetUri.uri,
17
+ 'cache-control': 'public, max-age=60',
18
+ });
19
+ res.sendStatus(302);
20
+ return;
21
+ }
12
22
  const asset = await assetRegistry.getAsset({ ...assetId, signature }, runtimeEnvironment, req.isSiteGeneration());
13
23
  if (req.isSiteGeneration()) {
14
24
  res.setSiteGenerationMetadata({ asset });
@@ -16,6 +26,12 @@ function createAssetMiddleware(context) {
16
26
  if (asset.mime) {
17
27
  res.type(asset.mime);
18
28
  }
29
+ if (runtimeEnvironment.immutableAssets && immutable) {
30
+ res.setHeader('Cache-control', 'public, max-age=12895706, immutable');
31
+ }
32
+ else if (runtimeEnvironment.immutableAssets) {
33
+ res.setHeader('Cache-control', 'public, max-age=60');
34
+ }
19
35
  res.status(200).stream(asset.stream());
20
36
  };
21
37
  }
@@ -45,15 +45,13 @@ export function getResourceIdentity(req) {
45
45
  export function getAssetIdentity(req) {
46
46
  const { signature, immutable, assetType: type } = req.params;
47
47
  const specifier = signature && type ? '/' + req.params[0] : req.originalUrl.split('?')[0];
48
- if (immutable) {
49
- // WIP: ?
50
- }
51
48
  if (validateSpecifier(specifier) === false) {
52
49
  throw createSingleDiagnosticError({
53
50
  description: descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier),
54
51
  }, LwrUnresolvableError);
55
52
  }
56
53
  return {
54
+ immutable,
57
55
  assetId: {
58
56
  specifier,
59
57
  type,
@@ -6,6 +6,7 @@ export default class SiteGenerator {
6
6
  * - Generate all routes / modules
7
7
  * - copy assets / resources
8
8
  *
9
+ * @deprecated - use new build api
9
10
  * @param config - LWR config for the site
10
11
  * @param dispatcher - Facilitate server requests
11
12
  */
@@ -90,6 +91,8 @@ export default class SiteGenerator {
90
91
  *
91
92
  */
92
93
  private copyAssets;
94
+ private addAssetsToMetadata;
95
+ private addAssetToMetadata;
93
96
  /**
94
97
  * Create a new site config for the current view
95
98
  */
@@ -100,7 +103,7 @@ export default class SiteGenerator {
100
103
  */
101
104
  private addAdditionalImportMetadataToViewConfig;
102
105
  /**
103
- * Capure additional metadata collected during the processing of a route or additional module
106
+ * Capture additional metadata collected during the processing of a route or additional module
104
107
  */
105
108
  private captureAdditionalRouteMetadata;
106
109
  }
@@ -1,6 +1,6 @@
1
1
  import { performance } from 'perf_hooks';
2
- import { getSpecifier, getFeatureFlags, hashContent, isSelfUrl, getModuleUriPrefix, getMappingUriPrefix, logger, WARN, INFO, SiteMetadataImpl, isExternalUrl, } from '@lwrjs/shared-utils';
3
- import { join, dirname, extname } from 'path';
2
+ import { getSpecifier, getFeatureFlags, hashContent, isSelfUrl, getModuleUriPrefix, getMappingUriPrefix, logger, WARN, INFO, SiteMetadataImpl, isExternalUrl, mimeLookup, } from '@lwrjs/shared-utils';
3
+ import { join, dirname, extname, normalize } from 'path';
4
4
  import fs from 'fs-extra';
5
5
  import { writeResponse } from './utils/stream.js';
6
6
  import { createDir, createResourceDir } from './utils/dir.js';
@@ -11,6 +11,7 @@ export default class SiteGenerator {
11
11
  * - Generate all routes / modules
12
12
  * - copy assets / resources
13
13
  *
14
+ * @deprecated - use new build api
14
15
  * @param config - LWR config for the site
15
16
  * @param dispatcher - Facilitate server requests
16
17
  */
@@ -41,7 +42,7 @@ export default class SiteGenerator {
41
42
  // Write redirect files
42
43
  this.writeNetlifyRedirectConfig(outputDir, urlRewriteMap);
43
44
  // Copy over assets
44
- this.copyAssets(assets, outputDir, basePath);
45
+ await this.copyAssets(assets, outputDir, config);
45
46
  const endTime = performance.now();
46
47
  const timeDiff = (endTime - startTime) / 1000;
47
48
  logger.info(`[SSG] Static Site Generation complete in ${Math.round(timeDiff)} seconds`);
@@ -184,11 +185,11 @@ export default class SiteGenerator {
184
185
  // Redirect encoded signed URIs to UNencoded signed URIs
185
186
  // e.g. /1/bundle/amd/l/en-US/bi/0/module/mi/c%2Fmodule%2Fv%2F0_1_6/s/{signature} -> /1/bundle/amd/l/en-US/bi/0/module/mi/c/module/v/0_1_6/s/{signature}
186
187
  siteConfig.urlRewriteMap.set(url.substring(0, url.indexOf('/s/')), normalizedUrl);
187
- // Redirect unversioned/unsigned URIs to signed URIs
188
+ // Redirect un-versioned/unsigned URIs to signed URIs
188
189
  // e.g. /1/bundle/amd/l/en-US/bi/0/module/mi/c/module -> /1/bundle/amd/l/en-US/bi/0/module/mi/c/module/v/0_1_6/s/{signature}
189
190
  // e.g. with importer /1/bundle/amd/l/en-US/bi/0/module/mi/c/module?importer=parent%2Fmodule%2Fv%2F2_1_0 -> /1/bundle/amd/l/en-US/bi/0/module/mi/c/module/v/0_1_6/s/{signature}
190
191
  siteConfig.urlRewriteMap.set(normalizedUrl.substring(0, normalizedUrl.indexOf('/v/')), normalizedUrl);
191
- // Redirect encoded unversioned/unsigned URIs to UNencoded signed URIs
192
+ // Redirect encoded un-versioned/unsigned URIs to UNencoded signed URIs
192
193
  // e.g. /1/bundle/amd/l/en-US/bi/0/module/mi/c%2Fmodule -> /1/bundle/amd/l/en-US/bi/0/module/mi/c/module/v/0_1_6/s/{signature}
193
194
  // e.g. with importer /1/bundle/amd/l/en-US/bi/0/module/mi/c%2Fmodule?importer=parent%2Fmodule%2Fv%2F2_1_0 -> /1/bundle/amd/l/en-US/bi/0/module/mi/c/module/v/0_1_6/s/{signature}
194
195
  siteConfig.urlRewriteMap.set(url.substring(0, url.indexOf('%2Fv%2F')), normalizedUrl);
@@ -270,7 +271,13 @@ export default class SiteGenerator {
270
271
  mimeType: String(assetDefinition.mime),
271
272
  };
272
273
  const siteAssets = siteConfig.siteMetadata.getSiteAssets();
273
- siteAssets.assets[specifier] = resourceMetadata;
274
+ // Do not overwrite
275
+ if (!siteAssets.assets[specifier]) {
276
+ siteAssets.assets[specifier] = resourceMetadata;
277
+ }
278
+ else {
279
+ logger.debug(`[SSG] Ignore asset redefinition ${specifier}`);
280
+ }
274
281
  }
275
282
  }
276
283
  }
@@ -282,22 +289,22 @@ export default class SiteGenerator {
282
289
  * @param dispatcher - Network dispatcher
283
290
  */
284
291
  async handleMappingResource(url, context, siteConfig, dispatcher) {
285
- const { importMetadata: importMetatdata } = siteConfig;
292
+ const { importMetadata: importMetadata } = siteConfig;
286
293
  const statusCode = context.response?.status;
287
294
  // Received a server error
288
295
  if (statusCode === 200) {
289
296
  // Read JSON
290
297
  const newImportMetadata = context.fs?.body;
291
298
  let filteredImportMetadata;
292
- if (!importMetatdata) {
299
+ if (!importMetadata) {
293
300
  filteredImportMetadata = newImportMetadata;
294
301
  }
295
302
  else {
296
303
  // need to handle importMetadata when generating from a view
297
- filteredImportMetadata = importMetatdata.addAdditionalMetadata(newImportMetadata);
304
+ filteredImportMetadata = importMetadata.addAdditionalMetadata(newImportMetadata);
298
305
  }
299
306
  // Filter out and import metadata already included with the view
300
- // const filteredImportMetadata = importMetatdata.addAdditionalMetadata(newImportMetadata);
307
+ // const filteredImportMetadata = importMetadata.addAdditionalMetadata(newImportMetadata);
301
308
  // Build up a list of dispatch requests to kick off in parallel
302
309
  const dispatchRequests = [];
303
310
  // Iterate through the import mappings and return request uris
@@ -533,22 +540,72 @@ export default class SiteGenerator {
533
540
  * @param assets AssetConfig
534
541
  *
535
542
  */
536
- copyAssets(assets, outputDir, basePath) {
543
+ async copyAssets(assets, outputDir, config) {
544
+ const { basePath } = config;
545
+ const runtimeEnvironment = getRuntimeEnvironment(config);
546
+ const siteConfig = this.createSiteConfig(outputDir, 'en-US', // Copy Assets should not use the locale
547
+ new Map(), true, runtimeEnvironment);
537
548
  for (const asset of assets) {
538
549
  try {
539
- const assetSrcDir = asset.dir || asset.file;
540
- const assetOutputDir = join(outputDir, basePath ? basePath + asset.urlPath : asset.urlPath);
550
+ const assetSrcFile = asset.file;
551
+ const assetSrcDir = asset.dir;
552
+ const assetsPath = join(outputDir, basePath ? basePath + asset.urlPath : asset.urlPath);
541
553
  if (assetSrcDir && fs.existsSync(assetSrcDir)) {
542
- fs.copySync(assetSrcDir, assetOutputDir);
554
+ fs.copySync(assetSrcDir, assetsPath);
555
+ this.addAssetsToMetadata(assetsPath, siteConfig);
556
+ }
557
+ else if (assetSrcFile && fs.existsSync(assetSrcFile)) {
558
+ fs.copySync(assetSrcFile, assetsPath);
559
+ this.addAssetToMetadata(assetsPath, siteConfig);
543
560
  }
544
561
  else {
545
- logger.warn('[SSG] Could not find assets to copy at path: ' + assetSrcDir);
562
+ logger.warn('[SSG] Could not find assets to copy at path: ' + assetsPath);
546
563
  }
547
564
  }
548
565
  catch (e) {
549
566
  logger.error('[SSG] Error occurred processing asset config: ' + JSON.stringify(asset), e);
550
567
  }
551
568
  }
569
+ await siteConfig.siteMetadata?.persistSiteMetadata();
570
+ }
571
+ addAssetsToMetadata(directoryPath, siteConfig) {
572
+ try {
573
+ const files = fs.readdirSync(directoryPath);
574
+ for (const file of files) {
575
+ const filePath = join(directoryPath, file);
576
+ if (fs.statSync(filePath).isDirectory()) {
577
+ this.addAssetsToMetadata(filePath, siteConfig);
578
+ }
579
+ else {
580
+ this.addAssetToMetadata(filePath, siteConfig);
581
+ }
582
+ }
583
+ }
584
+ catch (err) {
585
+ logger.warn(`[SSG] Unexpected error collecting asset directory metadata for ${directoryPath}`, err);
586
+ }
587
+ }
588
+ addAssetToMetadata(filePath, siteConfig) {
589
+ try {
590
+ const uri = encodeURI(normalize(filePath).replace(siteConfig.outputDir, ''));
591
+ this.addAssetToSiteMetadata({
592
+ uri,
593
+ type: 'asset',
594
+ stream: function (encoding) {
595
+ throw new Error('Function not implemented.');
596
+ },
597
+ entry: filePath,
598
+ ext: extname(filePath),
599
+ mime: mimeLookup(filePath),
600
+ ownHash: 'not-provided',
601
+ content: function (encoding) {
602
+ throw new Error('Function not implemented.');
603
+ },
604
+ }, uri, siteConfig);
605
+ }
606
+ catch (err) {
607
+ logger.warn(`[SSG] Unexpected error collecting asset metadata for ${filePath}`, err);
608
+ }
552
609
  }
553
610
  /**
554
611
  * Create a new site config for the current view
@@ -578,13 +635,13 @@ export default class SiteGenerator {
578
635
  filterFeatureFlags() {
579
636
  const ffs = getFeatureFlags();
580
637
  if (ffs && Object.keys(ffs).length) {
581
- const accumlator = {};
638
+ const accumulator = {};
582
639
  for (const [key, value] of Object.entries(ffs)) {
583
640
  if (value) {
584
- accumlator[key] = true;
641
+ accumulator[key] = true;
585
642
  }
586
643
  }
587
- return { featureFlags: accumlator };
644
+ return { featureFlags: accumulator };
588
645
  }
589
646
  else {
590
647
  return undefined;
@@ -631,7 +688,7 @@ export default class SiteGenerator {
631
688
  }
632
689
  }
633
690
  /**
634
- * Capure additional metadata collected during the processing of a route or additional module
691
+ * Capture additional metadata collected during the processing of a route or additional module
635
692
  */
636
693
  async captureAdditionalRouteMetadata(siteConfig) {
637
694
  // If there is a view config add any extra collected import metadata to the config
@@ -682,10 +739,10 @@ export class ViewImportMetadataImpl {
682
739
  /**
683
740
  * Merge new import metadata into target import metadata
684
741
  */
685
- mergeImportMetadata(targetImportMetdadata, newImportMetadata) {
686
- Object.assign(targetImportMetdadata.imports, newImportMetadata.imports);
687
- if (targetImportMetdadata.index) {
688
- Object.assign(targetImportMetdadata.index, newImportMetadata.index || {});
742
+ mergeImportMetadata(targetImportMetadata, newImportMetadata) {
743
+ Object.assign(targetImportMetadata.imports, newImportMetadata.imports);
744
+ if (targetImportMetadata.index) {
745
+ Object.assign(targetImportMetadata.index, newImportMetadata.index || {});
689
746
  }
690
747
  }
691
748
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.9.0-alpha.26",
7
+ "version": "0.9.0-alpha.28",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -37,39 +37,39 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@locker/compiler": "0.18.9",
40
- "@lwrjs/app-service": "0.9.0-alpha.26",
41
- "@lwrjs/asset-registry": "0.9.0-alpha.26",
42
- "@lwrjs/asset-transformer": "0.9.0-alpha.26",
43
- "@lwrjs/base-view-provider": "0.9.0-alpha.26",
44
- "@lwrjs/base-view-transformer": "0.9.0-alpha.26",
45
- "@lwrjs/client-modules": "0.9.0-alpha.26",
46
- "@lwrjs/config": "0.9.0-alpha.26",
47
- "@lwrjs/diagnostics": "0.9.0-alpha.26",
48
- "@lwrjs/fs-asset-provider": "0.9.0-alpha.26",
49
- "@lwrjs/html-view-provider": "0.9.0-alpha.26",
50
- "@lwrjs/loader": "0.9.0-alpha.26",
51
- "@lwrjs/lwc-module-provider": "0.9.0-alpha.26",
52
- "@lwrjs/markdown-view-provider": "0.9.0-alpha.26",
53
- "@lwrjs/module-bundler": "0.9.0-alpha.26",
54
- "@lwrjs/module-registry": "0.9.0-alpha.26",
55
- "@lwrjs/npm-module-provider": "0.9.0-alpha.26",
56
- "@lwrjs/nunjucks-view-provider": "0.9.0-alpha.26",
57
- "@lwrjs/o11y": "0.9.0-alpha.26",
58
- "@lwrjs/resource-registry": "0.9.0-alpha.26",
59
- "@lwrjs/router": "0.9.0-alpha.26",
60
- "@lwrjs/server": "0.9.0-alpha.26",
61
- "@lwrjs/shared-utils": "0.9.0-alpha.26",
62
- "@lwrjs/view-registry": "0.9.0-alpha.26",
40
+ "@lwrjs/app-service": "0.9.0-alpha.28",
41
+ "@lwrjs/asset-registry": "0.9.0-alpha.28",
42
+ "@lwrjs/asset-transformer": "0.9.0-alpha.28",
43
+ "@lwrjs/base-view-provider": "0.9.0-alpha.28",
44
+ "@lwrjs/base-view-transformer": "0.9.0-alpha.28",
45
+ "@lwrjs/client-modules": "0.9.0-alpha.28",
46
+ "@lwrjs/config": "0.9.0-alpha.28",
47
+ "@lwrjs/diagnostics": "0.9.0-alpha.28",
48
+ "@lwrjs/fs-asset-provider": "0.9.0-alpha.28",
49
+ "@lwrjs/html-view-provider": "0.9.0-alpha.28",
50
+ "@lwrjs/loader": "0.9.0-alpha.28",
51
+ "@lwrjs/lwc-module-provider": "0.9.0-alpha.28",
52
+ "@lwrjs/markdown-view-provider": "0.9.0-alpha.28",
53
+ "@lwrjs/module-bundler": "0.9.0-alpha.28",
54
+ "@lwrjs/module-registry": "0.9.0-alpha.28",
55
+ "@lwrjs/npm-module-provider": "0.9.0-alpha.28",
56
+ "@lwrjs/nunjucks-view-provider": "0.9.0-alpha.28",
57
+ "@lwrjs/o11y": "0.9.0-alpha.28",
58
+ "@lwrjs/resource-registry": "0.9.0-alpha.28",
59
+ "@lwrjs/router": "0.9.0-alpha.28",
60
+ "@lwrjs/server": "0.9.0-alpha.28",
61
+ "@lwrjs/shared-utils": "0.9.0-alpha.28",
62
+ "@lwrjs/view-registry": "0.9.0-alpha.28",
63
63
  "chokidar": "^3.5.3",
64
64
  "esbuild": "^0.9.7",
65
- "fs-extra": "^10.1.0",
65
+ "fs-extra": "^11.1.0",
66
66
  "path-to-regexp": "^6.2.0",
67
67
  "qs": "^6.9.4",
68
68
  "rollup": "~2.45.2",
69
69
  "ws": "^8.8.1"
70
70
  },
71
71
  "devDependencies": {
72
- "@lwrjs/types": "0.9.0-alpha.26",
72
+ "@lwrjs/types": "0.9.0-alpha.28",
73
73
  "@types/ws": "^8.5.3"
74
74
  },
75
75
  "peerDependencies": {
@@ -78,5 +78,5 @@
78
78
  "engines": {
79
79
  "node": ">=16.0.0 <20"
80
80
  },
81
- "gitHead": "6da956eb29622d49423b0a6ee63300de1f3e121c"
81
+ "gitHead": "da7d0c58d2e34958a289a18f43c5998e85e72986"
82
82
  }