@lwrjs/shared-utils 0.13.0-alpha.13 → 0.13.0-alpha.15

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.
@@ -27,7 +27,6 @@ __export(exports, {
27
27
  ASSETS_CACHE_DIR: () => ASSETS_CACHE_DIR,
28
28
  BUNDLE_SIGIL: () => BUNDLE_SIGIL,
29
29
  DEFAULT_LOCKER_TRUSTED_CMP: () => DEFAULT_LOCKER_TRUSTED_CMP,
30
- DEFAULT_LWR_BOOTSTRAP_CONFIG: () => DEFAULT_LWR_BOOTSTRAP_CONFIG,
31
30
  DEFAULT_LWR_LOCKER_CONFIG: () => DEFAULT_LWR_LOCKER_CONFIG,
32
31
  DEFAULT_TITLE: () => DEFAULT_TITLE,
33
32
  ENVIRONMENT_SIGIL: () => ENVIRONMENT_SIGIL,
@@ -75,18 +74,6 @@ var DEFAULT_LWR_LOCKER_CONFIG = {
75
74
  enabled: false,
76
75
  trustedComponents: DEFAULT_LOCKER_TRUSTED_CMP
77
76
  };
78
- var DEFAULT_LWR_BOOTSTRAP_CONFIG = {
79
- autoBoot: true,
80
- syntheticShadow: false,
81
- workers: {},
82
- services: [],
83
- configAsSrc: false,
84
- ssr: false,
85
- preloadData: false,
86
- mixedMode: false,
87
- module: void 0,
88
- preloadModules: []
89
- };
90
77
  function normalizeVersionToUri(version) {
91
78
  return version.replace(/\./g, "_");
92
79
  }
@@ -62,8 +62,8 @@ async function getImportMetadataMappings(moduleIds, runtimeEnvironment, runtimeP
62
62
  }
63
63
  async function toImportMetadata(moduleGraph, existingImportMetadata = {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams = {}) {
64
64
  const specifier = moduleGraph.graphs[0].specifier;
65
- const uri = moduleGraph.uriMap[specifier];
66
- const definition = moduleGraph.linkedDefinitions[specifier];
65
+ const uri = lookupValueIgnoringVersion(moduleGraph.uriMap, specifier);
66
+ const definition = lookupValueIgnoringVersion(moduleGraph.linkedDefinitions, specifier);
67
67
  if (!uri) {
68
68
  throw new Error("URI was not included in the graph: " + specifier);
69
69
  }
@@ -83,8 +83,8 @@ async function toImportMetadata(moduleGraph, existingImportMetadata = {imports:
83
83
  if (isExternalSpecifier(depSpecifier, moduleRegistry.getConfig().bundleConfig)) {
84
84
  continue;
85
85
  }
86
- const depUri = moduleGraph.uriMap[depSpecifier];
87
- const depDef = moduleGraph.linkedDefinitions[depSpecifier];
86
+ const depUri = lookupValueIgnoringVersion(moduleGraph.uriMap, depSpecifier);
87
+ const depDef = lookupValueIgnoringVersion(moduleGraph.linkedDefinitions, depSpecifier);
88
88
  const depMissing = !depUri || !depDef;
89
89
  if (depMissing && runtimeEnvironment.format !== "esm") {
90
90
  if (!depUri) {
@@ -106,6 +106,18 @@ async function toImportMetadata(moduleGraph, existingImportMetadata = {imports:
106
106
  }
107
107
  return importMetadata;
108
108
  }
109
+ function lookupValueIgnoringVersion(map, specifier) {
110
+ const val = map[specifier];
111
+ if (val) {
112
+ return val;
113
+ }
114
+ const cleanedKey = (0, import_identity.explodeSpecifier)(specifier).specifier;
115
+ for (const mapKey of Object.keys(map)) {
116
+ if ((0, import_identity.explodeSpecifier)(mapKey).specifier === cleanedKey) {
117
+ return map[mapKey];
118
+ }
119
+ }
120
+ }
109
121
  function mergeImportMetadata(existing, newMetadata) {
110
122
  return {
111
123
  imports: {
@@ -1,5 +1,5 @@
1
1
  import getCacheKeyFromJson from 'fast-json-stable-stringify';
2
- import type { AbstractModuleId, AssetSource, BundleDefinition, ModuleDefinition, NormalizedLwrAppBootstrapConfig, PublicModuleRegistry, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
2
+ import type { AbstractModuleId, AssetSource, BundleDefinition, ModuleDefinition, PublicModuleRegistry, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
3
3
  export declare const VERSION_SIGIL = "v";
4
4
  export declare const VERSION_PREFIX: string;
5
5
  export declare const LOCALE_SIGIL = "l";
@@ -15,7 +15,6 @@ export declare const DEFAULT_LWR_LOCKER_CONFIG: {
15
15
  enabled: boolean;
16
16
  trustedComponents: string[];
17
17
  };
18
- export declare const DEFAULT_LWR_BOOTSTRAP_CONFIG: NormalizedLwrAppBootstrapConfig;
19
18
  type ModuleIdentifierPartial = Partial<AbstractModuleId>;
20
19
  /**
21
20
  * Turn the dots in a version into underscores
@@ -16,18 +16,6 @@ export const DEFAULT_LWR_LOCKER_CONFIG = {
16
16
  enabled: false,
17
17
  trustedComponents: DEFAULT_LOCKER_TRUSTED_CMP,
18
18
  };
19
- export const DEFAULT_LWR_BOOTSTRAP_CONFIG = {
20
- autoBoot: true,
21
- syntheticShadow: false,
22
- workers: {},
23
- services: [],
24
- configAsSrc: false,
25
- ssr: false,
26
- preloadData: false,
27
- mixedMode: false,
28
- module: undefined,
29
- preloadModules: [],
30
- };
31
19
  /**
32
20
  * Turn the dots in a version into underscores
33
21
  * @param version
@@ -57,8 +57,8 @@ export async function getImportMetadataMappings(moduleIds, runtimeEnvironment, r
57
57
  export async function toImportMetadata(moduleGraph, existingImportMetadata = { imports: {}, index: {} }, moduleRegistry, runtimeEnvironment, runtimeParams = {}) {
58
58
  // root module specifier
59
59
  const specifier = moduleGraph.graphs[0].specifier;
60
- const uri = moduleGraph.uriMap[specifier];
61
- const definition = moduleGraph.linkedDefinitions[specifier];
60
+ const uri = lookupValueIgnoringVersion(moduleGraph.uriMap, specifier);
61
+ const definition = lookupValueIgnoringVersion(moduleGraph.linkedDefinitions, specifier);
62
62
  if (!uri) {
63
63
  throw new Error('URI was not included in the graph: ' + specifier);
64
64
  }
@@ -86,8 +86,8 @@ export async function toImportMetadata(moduleGraph, existingImportMetadata = { i
86
86
  // Ignore Externals
87
87
  continue;
88
88
  }
89
- const depUri = moduleGraph.uriMap[depSpecifier];
90
- const depDef = moduleGraph.linkedDefinitions[depSpecifier];
89
+ const depUri = lookupValueIgnoringVersion(moduleGraph.uriMap, depSpecifier);
90
+ const depDef = lookupValueIgnoringVersion(moduleGraph.linkedDefinitions, depSpecifier);
91
91
  const depMissing = !depUri || !depDef;
92
92
  if (depMissing && runtimeEnvironment.format !== 'esm') {
93
93
  if (!depUri) {
@@ -112,6 +112,21 @@ export async function toImportMetadata(moduleGraph, existingImportMetadata = { i
112
112
  }
113
113
  return importMetadata;
114
114
  }
115
+ // Function to look up values ignoring the version part
116
+ function lookupValueIgnoringVersion(map, specifier) {
117
+ // early out on exact match
118
+ const val = map[specifier];
119
+ if (val) {
120
+ return val;
121
+ }
122
+ const cleanedKey = explodeSpecifier(specifier).specifier;
123
+ // Iterate over the map to find the first matching key without version
124
+ for (const mapKey of Object.keys(map)) {
125
+ if (explodeSpecifier(mapKey).specifier === cleanedKey) {
126
+ return map[mapKey];
127
+ }
128
+ }
129
+ }
115
130
  function mergeImportMetadata(existing, newMetadata) {
116
131
  // TODO should there be an error if the metadata conflicts?
117
132
  return {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.0-alpha.13",
7
+ "version": "0.13.0-alpha.15",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -37,8 +37,8 @@
37
37
  "build/**/*.d.ts"
38
38
  ],
39
39
  "dependencies": {
40
- "@lwrjs/diagnostics": "0.13.0-alpha.13",
41
- "es-module-lexer": "^1.5.2",
40
+ "@lwrjs/diagnostics": "0.13.0-alpha.15",
41
+ "es-module-lexer": "^1.5.3",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "magic-string": "^0.30.9",
44
44
  "mime-types": "^2.1.33",
@@ -50,12 +50,12 @@
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.13.0-alpha.13",
53
+ "@lwrjs/types": "0.13.0-alpha.15",
54
54
  "@types/mime-types": "2.1.4",
55
55
  "@types/path-to-regexp": "^1.7.0"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=18.0.0"
59
59
  },
60
- "gitHead": "7ef5235dbf1a8c5895fb8acdb212c50f715f0a03"
60
+ "gitHead": "d5eab85249493caf8766c4bc400b11d9c0a9909e"
61
61
  }