@lwrjs/static 0.21.7 → 0.22.1

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.
@@ -64,14 +64,14 @@ var StaticAssetProvider = class {
64
64
  }
65
65
  return void 0;
66
66
  }
67
- const siteAssetPath = import_path.default.join(this.siteRootDir, metadata.path);
67
+ const siteAssetPath = (0, import_shared_utils.joinUrlPath)(this.siteRootDir, metadata.path);
68
68
  const mime = metadata.mimeType || (0, import_shared_utils.mimeLookup)(siteAssetPath);
69
69
  const ext = import_path.default.extname(`x.${siteAssetPath}`).toLowerCase().substring(1);
70
70
  const type = this.assetsOnLambda ? "asset" : "external";
71
71
  const content = function(encoding) {
72
72
  return import_fs_extra.default.readFileSync(siteAssetPath, encoding);
73
73
  };
74
- const uri = this.assetsOnLambda ? fileAssetPath : import_path.default.join(this.siteRootDir, fileAssetPath);
74
+ const uri = this.assetsOnLambda ? fileAssetPath : (0, import_shared_utils.joinUrlPath)(this.siteRootDir, fileAssetPath);
75
75
  import_diagnostics.logger.debug({label: `${this.name}`, message: `uri ${assetIdentifier.specifier} -> ${uri}`});
76
76
  return {
77
77
  entry: siteAssetPath,
@@ -85,7 +85,7 @@ var StaticBundleProvider = class {
85
85
  this.logBundleError(moduleId, localeId, debug, ssr);
86
86
  return void 0;
87
87
  }
88
- const bundlePath = import_path.default.join(this.siteRootDir, metadata.path);
88
+ const bundlePath = (0, import_shared_utils.joinUrlPath)(this.siteRootDir, metadata.path);
89
89
  const resolvedBundlePath = this.getCodePath(bundlePath, debug, specifier, version, localeId, ssr);
90
90
  const codePromiser = this.getCodePromiser(resolvedBundlePath, {
91
91
  specifier,
@@ -238,7 +238,7 @@ var StaticBundleProvider = class {
238
238
  });
239
239
  return BUNDLE_SOURCE_NOT_FOUND;
240
240
  }
241
- bundleSourcePath = import_path.default.join(this.siteRootDir, metadata.path);
241
+ bundleSourcePath = (0, import_shared_utils.joinUrlPath)(this.siteRootDir, metadata.path);
242
242
  }
243
243
  return bundleSourcePath;
244
244
  }
@@ -28,7 +28,6 @@ __export(exports, {
28
28
  });
29
29
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
30
30
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
31
- var import_path = __toModule(require("path"));
32
31
  var import_site_metadata = __toModule(require("../site-metadata.cjs"));
33
32
  var StaticModuleProvider = class {
34
33
  constructor(_config, context) {
@@ -65,7 +64,7 @@ var StaticModuleProvider = class {
65
64
  label: `${this.name}`,
66
65
  message: `Module Entry request for static bundle ${specifier}`
67
66
  });
68
- const bundlePath = import_path.default.join(this.siteRootDir, metadata.path);
67
+ const bundlePath = (0, import_shared_utils.joinUrlPath)(this.siteRootDir, metadata.path);
69
68
  const resolvedVersion = (0, import_site_metadata.resolveStaticBundleVersion)(metadata.version, version);
70
69
  return {
71
70
  id: (0, import_shared_utils.getSpecifier)({...moduleId, version: resolvedVersion}),
@@ -105,7 +104,7 @@ function buildFingerprintsIndex(context) {
105
104
  if (!context.runtimeEnvironment.featureFlags.LEGACY_LOADER) {
106
105
  const bundles = context.siteMetadata?.getSiteBundles().bundles || {};
107
106
  for (const bundle of Object.values(bundles)) {
108
- const bundlePath = import_path.default.join(String(context.siteMetadata?.getSiteRootDir()), bundle.path);
107
+ const bundlePath = (0, import_shared_utils.joinUrlPath)(String(context.siteMetadata?.getSiteRootDir()), bundle.path);
109
108
  const includedModules = bundle.includedModules || [];
110
109
  for (const includedModule of includedModules) {
111
110
  const versionedSpecifier = convertSiteIdToVersionedSpecifier(includedModule);
@@ -52,7 +52,7 @@ var StaticResourceProvider = class {
52
52
  });
53
53
  return void 0;
54
54
  }
55
- const resourcePath = import_path.default.join(this.siteRootDir, resourceMetadata.path);
55
+ const resourcePath = (0, import_shared_utils.joinUrlPath)(this.siteRootDir, resourceMetadata.path);
56
56
  const type = resourceMetadata.mimeType || (0, import_shared_utils.mimeLookup)(resourcePath) || "application/javascript";
57
57
  return {
58
58
  type,
@@ -48,7 +48,7 @@ async function dedupeBundles(rootDir, i18n) {
48
48
  if (!localeId || localeId === i18n.defaultLocale) {
49
49
  continue;
50
50
  }
51
- const currentPath = import_path.default.join(rootDir, metadata.path);
51
+ const currentPath = (0, import_shared_utils.joinUrlPath)(rootDir, metadata.path);
52
52
  const currentSrc = import_fs_extra.default.readFileSync(currentPath);
53
53
  import_diagnostics.logger.debug({
54
54
  label: `dedupeBundles`,
@@ -58,7 +58,7 @@ async function dedupeBundles(rootDir, i18n) {
58
58
  const fallBackLocale = locale?.fallback ?? i18n.defaultLocale;
59
59
  const fallbackMetadata = decisionTree.find(siteIdStr, false, false, fallBackLocale);
60
60
  if (fallbackMetadata) {
61
- const fallbackSrc = import_fs_extra.default.readFileSync(import_path.default.join(rootDir, fallbackMetadata.path));
61
+ const fallbackSrc = import_fs_extra.default.readFileSync((0, import_shared_utils.joinUrlPath)(rootDir, fallbackMetadata.path));
62
62
  import_diagnostics.logger.debug({
63
63
  label: `dedupeBundles`,
64
64
  message: `fallback ${siteIdStr},${fallBackLocale} -> ${(0, import_shared_utils.hashContent)(fallbackSrc)}`
@@ -1,5 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import { hashContent, mimeLookup, normalizeResourcePath } from '@lwrjs/shared-utils';
2
+ import { hashContent, joinUrlPath, mimeLookup, normalizeResourcePath } from '@lwrjs/shared-utils';
3
3
  import path from 'path';
4
4
  import fs from 'fs-extra';
5
5
  export default class StaticAssetProvider {
@@ -46,7 +46,7 @@ export default class StaticAssetProvider {
46
46
  return undefined;
47
47
  }
48
48
  // FS path including ssg root
49
- const siteAssetPath = path.join(this.siteRootDir, metadata.path);
49
+ const siteAssetPath = joinUrlPath(this.siteRootDir, metadata.path);
50
50
  // Figure out mime type
51
51
  const mime = metadata.mimeType || mimeLookup(siteAssetPath);
52
52
  // Normalize extension
@@ -57,7 +57,7 @@ export default class StaticAssetProvider {
57
57
  return fs.readFileSync(siteAssetPath, encoding);
58
58
  };
59
59
  // Create URI
60
- const uri = this.assetsOnLambda ? fileAssetPath : path.join(this.siteRootDir, fileAssetPath);
60
+ const uri = this.assetsOnLambda ? fileAssetPath : joinUrlPath(this.siteRootDir, fileAssetPath);
61
61
  logger.debug({ label: `${this.name}`, message: `uri ${assetIdentifier.specifier} -> ${uri}` });
62
62
  return {
63
63
  entry: siteAssetPath,
@@ -1,5 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import { VERSION_SIGIL, explodeSpecifier, getSpecifier, isExternalSpecifier, isLambdaEnv, normalizeFromFileURL, } from '@lwrjs/shared-utils';
2
+ import { VERSION_SIGIL, explodeSpecifier, getSpecifier, isExternalSpecifier, isLambdaEnv, joinUrlPath, normalizeFromFileURL, } from '@lwrjs/shared-utils';
3
3
  import path from 'path';
4
4
  import fs from 'fs-extra';
5
5
  import { LRUCache } from 'lru-cache';
@@ -66,7 +66,7 @@ export default class StaticBundleProvider {
66
66
  return undefined;
67
67
  }
68
68
  // Default bundle source path
69
- const bundlePath = path.join(this.siteRootDir, metadata.path);
69
+ const bundlePath = joinUrlPath(this.siteRootDir, metadata.path);
70
70
  // Get the associated bundle source code
71
71
  const resolvedBundlePath = this.getCodePath(bundlePath, debug, specifier, version, localeId, ssr);
72
72
  const codePromiser = this.getCodePromiser(resolvedBundlePath, {
@@ -255,7 +255,7 @@ export default class StaticBundleProvider {
255
255
  return BUNDLE_SOURCE_NOT_FOUND;
256
256
  }
257
257
  // Overwrite the default source code path the prod source code path
258
- bundleSourcePath = path.join(this.siteRootDir, metadata.path);
258
+ bundleSourcePath = joinUrlPath(this.siteRootDir, metadata.path);
259
259
  }
260
260
  return bundleSourcePath;
261
261
  }
@@ -1,6 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import { VERSION_SIGIL, explodeSpecifier, getSpecifier, isLambdaEnv } from '@lwrjs/shared-utils';
3
- import path from 'path';
2
+ import { VERSION_SIGIL, explodeSpecifier, getSpecifier, isLambdaEnv, joinUrlPath } from '@lwrjs/shared-utils';
4
3
  import { getSiteBundleId, parseSiteId, resolveStaticBundleVersion } from '../site-metadata.js';
5
4
  export default class StaticModuleProvider {
6
5
  name = 'static-module-provider';
@@ -47,7 +46,7 @@ export default class StaticModuleProvider {
47
46
  message: `Module Entry request for static bundle ${specifier}`,
48
47
  });
49
48
  // Have to make the bundle code available for SSR
50
- const bundlePath = path.join(this.siteRootDir, metadata.path);
49
+ const bundlePath = joinUrlPath(this.siteRootDir, metadata.path);
51
50
  const resolvedVersion = resolveStaticBundleVersion(metadata.version, version);
52
51
  return {
53
52
  id: getSpecifier({ ...moduleId, version: resolvedVersion }),
@@ -88,7 +87,7 @@ function buildFingerprintsIndex(context) {
88
87
  if (!context.runtimeEnvironment.featureFlags.LEGACY_LOADER) {
89
88
  const bundles = context.siteMetadata?.getSiteBundles().bundles || {};
90
89
  for (const bundle of Object.values(bundles)) {
91
- const bundlePath = path.join(String(context.siteMetadata?.getSiteRootDir()), bundle.path);
90
+ const bundlePath = joinUrlPath(String(context.siteMetadata?.getSiteRootDir()), bundle.path);
92
91
  const includedModules = bundle.includedModules || [];
93
92
  for (const includedModule of includedModules) {
94
93
  const versionedSpecifier = convertSiteIdToVersionedSpecifier(includedModule);
@@ -1,5 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import { mimeLookup } from '@lwrjs/shared-utils';
2
+ import { joinUrlPath, mimeLookup } from '@lwrjs/shared-utils';
3
3
  import path from 'path';
4
4
  import fs from 'fs-extra';
5
5
  import { getSiteResourceId } from '../site-metadata.js';
@@ -32,7 +32,7 @@ export default class StaticResourceProvider {
32
32
  });
33
33
  return undefined;
34
34
  }
35
- const resourcePath = path.join(this.siteRootDir, resourceMetadata.path);
35
+ const resourcePath = joinUrlPath(this.siteRootDir, resourceMetadata.path);
36
36
  // Figure out mime type
37
37
  const type = resourceMetadata.mimeType ||
38
38
  mimeLookup(resourcePath) ||
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
  import { logger } from '@lwrjs/diagnostics';
4
4
  import { SiteMetadataImpl, parseSiteId } from '../site-metadata.js';
5
- import { LOCALE_SIGIL, hashContent } from '@lwrjs/shared-utils';
5
+ import { LOCALE_SIGIL, hashContent, joinUrlPath } from '@lwrjs/shared-utils';
6
6
  export async function dedupeBundles(rootDir, i18n) {
7
7
  const siteMetadata = new SiteMetadataImpl({
8
8
  rootDir,
@@ -22,7 +22,7 @@ export async function dedupeBundles(rootDir, i18n) {
22
22
  continue;
23
23
  }
24
24
  // Read the content from the current metadata
25
- const currentPath = path.join(rootDir, metadata.path);
25
+ const currentPath = joinUrlPath(rootDir, metadata.path);
26
26
  const currentSrc = fs.readFileSync(currentPath);
27
27
  logger.debug({
28
28
  label: `dedupeBundles`,
@@ -34,7 +34,7 @@ export async function dedupeBundles(rootDir, i18n) {
34
34
  const fallbackMetadata = decisionTree.find(siteIdStr, false, false, fallBackLocale);
35
35
  if (fallbackMetadata) {
36
36
  // Read the content of the fallback metadata
37
- const fallbackSrc = fs.readFileSync(path.join(rootDir, fallbackMetadata.path));
37
+ const fallbackSrc = fs.readFileSync(joinUrlPath(rootDir, fallbackMetadata.path));
38
38
  logger.debug({
39
39
  label: `dedupeBundles`,
40
40
  message: `fallback ${siteIdStr},${fallBackLocale} -> ${hashContent(fallbackSrc)}`,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.21.7",
7
+ "version": "0.22.1",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -56,13 +56,13 @@
56
56
  "build/**/*.d.ts"
57
57
  ],
58
58
  "dependencies": {
59
- "@lwrjs/diagnostics": "0.21.7",
60
- "@lwrjs/instrumentation": "0.21.7",
61
- "@lwrjs/shared-utils": "0.21.7",
59
+ "@lwrjs/diagnostics": "0.22.1",
60
+ "@lwrjs/instrumentation": "0.22.1",
61
+ "@lwrjs/shared-utils": "0.22.1",
62
62
  "lru-cache": "^10.4.3"
63
63
  },
64
64
  "devDependencies": {
65
- "@lwrjs/types": "0.21.7",
65
+ "@lwrjs/types": "0.22.1",
66
66
  "@types/express": "^4.17.21",
67
67
  "jest": "29.7.0",
68
68
  "jest-express": "^1.12.0",
@@ -71,10 +71,10 @@
71
71
  "ts-jest": "^29.2.6"
72
72
  },
73
73
  "engines": {
74
- "node": ">=20.0.0"
74
+ "node": ">=22.0.0"
75
75
  },
76
76
  "volta": {
77
77
  "extends": "../../../package.json"
78
78
  },
79
- "gitHead": "685ec1660fd33420c61437bb3fcd37021036db12"
79
+ "gitHead": "29d44fb69ae394a4191c6a81024a8a81f2125556"
80
80
  }