@lwrjs/view-registry 0.11.4 → 0.11.6

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.
@@ -101,11 +101,17 @@ async function getHtmlResources(view, viewParams, resourceContext) {
101
101
  throw Error("Failed to find definition of resource: " + shimBundle);
102
102
  }
103
103
  }
104
+ if (!def.inline && !def.src) {
105
+ throw Error(`Invalid Shim ${shimBundle}: ${JSON.stringify(def)}`);
106
+ }
104
107
  requiredResources.push(def);
105
108
  const errorShimDef = await resourceRegistry.getResource({specifier: "lwr-error-shim.js", version}, runtimeEnvironment, runtimeParams);
106
109
  if (!errorShimDef) {
107
110
  throw Error("Failed to find definition of resource: lwr-error-shim.js");
108
111
  }
112
+ if (!errorShimDef.inline && !errorShimDef.src) {
113
+ throw Error(`Invalid Shim lwr-error-shim.js: ${JSON.stringify(errorShimDef)}`);
114
+ }
109
115
  requiredResources.push(errorShimDef);
110
116
  }
111
117
  const bootstrapModuleGraph = await (0, import_shared_utils.getModuleGraphs)(bootstrapSpecifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, visitedCache);
@@ -116,6 +122,9 @@ async function getHtmlResources(view, viewParams, resourceContext) {
116
122
  };
117
123
  versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
118
124
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
125
+ if (!uri) {
126
+ throw Error(`Invalid Module Resource ${versionedSpecifier}`);
127
+ }
119
128
  moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment, {isPreload: false, isSSR}));
120
129
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
121
130
  if (!isExternal(depSpecifier)) {
@@ -143,7 +152,10 @@ async function getHtmlResources(view, viewParams, resourceContext) {
143
152
  if (uri2) {
144
153
  imports[dynamicDep] = uri2;
145
154
  } else {
146
- import_diagnostics.logger.warn("Skipping unknown dynamic import " + dynamicDep);
155
+ import_diagnostics.logger.warn({
156
+ label: `view-registry`,
157
+ message: `Skipping unknown dynamic import: ${dynamicDep}`
158
+ });
147
159
  }
148
160
  }
149
161
  }
@@ -30,6 +30,9 @@ __export(exports, {
30
30
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
31
31
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
32
32
  function setPreloadModulesMeta(specifier, uri, groups, preloads) {
33
+ if (!uri) {
34
+ throw Error(`Invalid Preload Module ${specifier}`);
35
+ }
33
36
  const [removedVersion, version] = specifier.split("/v/");
34
37
  const normalizedSpecifier = version === import_shared_utils.VERSION_NOT_PROVIDED ? removedVersion : specifier;
35
38
  specifier = normalizedSpecifier;
@@ -55,7 +58,10 @@ async function getPreloadModulesMeta(specifier, viewPreloads, bundleConfig, modu
55
58
  return exclude.includes(specifier2);
56
59
  };
57
60
  if (isExternal(specifier)) {
58
- import_diagnostics.logger.warn(`"${specifier}" is configured in both bundleConfig.externals and bootstrap.preloadModules. We are treating it as external.`);
61
+ import_diagnostics.logger.warn({
62
+ label: `view-registry`,
63
+ message: `"${specifier}" is configured in both bundleConfig.externals and bootstrap.preloadModules. We are treating it as external.`
64
+ });
59
65
  } else {
60
66
  const versionedModuleId = await (0, import_shared_utils.getVersionedModuleId)(specifier, moduleRegistry, runtimeParams);
61
67
  const versionedModuleSpecifier = (0, import_shared_utils.getSpecifier)({
@@ -92,11 +92,17 @@ async function getHtmlResources(view, viewParams, resourceContext) {
92
92
  if (!def) {
93
93
  throw Error("Failed to find definition of resource: " + shimBundle);
94
94
  }
95
+ if (!def.inline && !def.src) {
96
+ throw Error(`Invalid Shim ${shimBundle}: ${JSON.stringify(def)}`);
97
+ }
95
98
  requiredResources.push(def);
96
99
  const errorShimDef = await resourceRegistry.getResource({specifier: "lwr-error-shim.js", version}, runtimeEnvironment, runtimeParams);
97
100
  if (!errorShimDef) {
98
101
  throw Error("Failed to find definition of resource: lwr-error-shim.js");
99
102
  }
103
+ if (!errorShimDef.inline && !errorShimDef.src) {
104
+ throw Error(`Invalid Shim lwr-error-shim.js: ${JSON.stringify(errorShimDef)}`);
105
+ }
100
106
  requiredResources.push(errorShimDef);
101
107
  }
102
108
  const bootstrapModuleGraph = await (0, import_shared_utils.getModuleGraphs)(bootstrapSpecifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, visitedCache);
@@ -107,6 +113,9 @@ async function getHtmlResources(view, viewParams, resourceContext) {
107
113
  };
108
114
  versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
109
115
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
116
+ if (!uri) {
117
+ throw Error(`Invalid Module Resource ${versionedSpecifier}`);
118
+ }
110
119
  moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment, {isPreload: false, isSSR}));
111
120
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
112
121
  if (!isExternal(depSpecifier)) {
@@ -134,7 +143,10 @@ async function getHtmlResources(view, viewParams, resourceContext) {
134
143
  if (uri2) {
135
144
  imports[dynamicDep] = uri2;
136
145
  } else {
137
- import_diagnostics.logger.warn("Skipping unknown dynamic import " + dynamicDep);
146
+ import_diagnostics.logger.warn({
147
+ label: `view-registry`,
148
+ message: `Skipping unknown dynamic import: ${dynamicDep}`
149
+ });
138
150
  }
139
151
  }
140
152
  }
@@ -94,12 +94,20 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
94
94
  throw Error('Failed to find definition of resource: ' + shimBundle);
95
95
  }
96
96
  }
97
+ // Throw a very specific error if we get this back and the src or inline properties are not set
98
+ if (!def.inline && !def.src) {
99
+ throw Error(`Invalid Shim ${shimBundle}: ${JSON.stringify(def)}`);
100
+ }
97
101
  requiredResources.push(def);
98
102
  // Always inline the error shim script after the shim
99
103
  const errorShimDef = (await resourceRegistry.getResource({ specifier: 'lwr-error-shim.js', version }, runtimeEnvironment, runtimeParams));
100
104
  if (!errorShimDef) {
101
105
  throw Error('Failed to find definition of resource: lwr-error-shim.js');
102
106
  }
107
+ // Throw a very specific error if we get this back and the src or inline properties are not set
108
+ if (!errorShimDef.inline && !errorShimDef.src) {
109
+ throw Error(`Invalid Shim lwr-error-shim.js: ${JSON.stringify(errorShimDef)}`);
110
+ }
103
111
  requiredResources.push(errorShimDef);
104
112
  }
105
113
  // ------- Application Bootstrap module
@@ -115,6 +123,10 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
115
123
  // ADD bootstrap module uri as a script resource
116
124
  versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
117
125
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
126
+ // Throw a very specific error if we get this back and the uri property is not set
127
+ if (!uri) {
128
+ throw Error(`Invalid Module Resource ${versionedSpecifier}`);
129
+ }
118
130
  moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: false, isSSR }));
119
131
  // PRELOAD the bootstrap module static dependencies as preloaded script resources
120
132
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
@@ -152,7 +164,10 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
152
164
  imports[dynamicDep] = uri;
153
165
  }
154
166
  else {
155
- logger.warn('Skipping unknown dynamic import ' + dynamicDep);
167
+ logger.warn({
168
+ label: `view-registry`,
169
+ message: `Skipping unknown dynamic import: ${dynamicDep}`,
170
+ });
156
171
  }
157
172
  }
158
173
  }
@@ -4,6 +4,10 @@ import { explodeSpecifier, getGroupName, getVersionedModuleId, normalizeVersionT
4
4
  * keeps track of preloadModules metadata
5
5
  */
6
6
  export function setPreloadModulesMeta(specifier, uri, groups, preloads) {
7
+ // Throw a very specific error if we get this back and the uri property is not set
8
+ if (!uri) {
9
+ throw Error(`Invalid Preload Module ${specifier}`);
10
+ }
7
11
  // We need to support version-less preloadModules, including version-less rootComponents.
8
12
  // Removing the "/v/version_not_provided" hack from the preloadModules specifier
9
13
  // because otherwise the loader will wait for that module that will never get defined.
@@ -39,7 +43,10 @@ viewPreloads, bundleConfig, moduleRegistry, defRegistry, runtimeEnvironment, run
39
43
  return exclude.includes(specifier);
40
44
  };
41
45
  if (isExternal(specifier)) {
42
- logger.warn(`"${specifier}" is configured in both bundleConfig.externals and bootstrap.preloadModules. We are treating it as external.`);
46
+ logger.warn({
47
+ label: `view-registry`,
48
+ message: `"${specifier}" is configured in both bundleConfig.externals and bootstrap.preloadModules. We are treating it as external.`,
49
+ });
43
50
  }
44
51
  else {
45
52
  // eslint-disable-next-line no-await-in-loop
@@ -79,12 +79,20 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
79
79
  if (!def) {
80
80
  throw Error('Failed to find definition of resource: ' + shimBundle);
81
81
  }
82
+ // Throw a very specific error if we get this back and the src or inline properties are not set
83
+ if (!def.inline && !def.src) {
84
+ throw Error(`Invalid Shim ${shimBundle}: ${JSON.stringify(def)}`);
85
+ }
82
86
  requiredResources.push(def);
83
87
  // Always inline the error shim script after the shim
84
88
  const errorShimDef = (await resourceRegistry.getResource({ specifier: 'lwr-error-shim.js', version }, runtimeEnvironment, runtimeParams));
85
89
  if (!errorShimDef) {
86
90
  throw Error('Failed to find definition of resource: lwr-error-shim.js');
87
91
  }
92
+ // Throw a very specific error if we get this back and the src or inline properties are not set
93
+ if (!errorShimDef.inline && !errorShimDef.src) {
94
+ throw Error(`Invalid Shim lwr-error-shim.js: ${JSON.stringify(errorShimDef)}`);
95
+ }
88
96
  requiredResources.push(errorShimDef);
89
97
  }
90
98
  // ------- Application Bootstrap module
@@ -99,6 +107,10 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
99
107
  // ADD bootstrap module uri as a script resource
100
108
  versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
101
109
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
110
+ // Throw a very specific error if we get this back and the uri property is not set
111
+ if (!uri) {
112
+ throw Error(`Invalid Module Resource ${versionedSpecifier}`);
113
+ }
102
114
  moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: false, isSSR }));
103
115
  // PRELOAD the bootstrap module static dependencies as preloaded script resources
104
116
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
@@ -136,7 +148,10 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
136
148
  imports[dynamicDep] = uri;
137
149
  }
138
150
  else {
139
- logger.warn('Skipping unknown dynamic import ' + dynamicDep);
151
+ logger.warn({
152
+ label: `view-registry`,
153
+ message: `Skipping unknown dynamic import: ${dynamicDep}`,
154
+ });
140
155
  }
141
156
  }
142
157
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.11.4",
7
+ "version": "0.11.6",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,17 +30,17 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@lwrjs/app-service": "0.11.4",
34
- "@lwrjs/diagnostics": "0.11.4",
35
- "@lwrjs/instrumentation": "0.11.4",
36
- "@lwrjs/shared-utils": "0.11.4",
33
+ "@lwrjs/app-service": "0.11.6",
34
+ "@lwrjs/diagnostics": "0.11.6",
35
+ "@lwrjs/instrumentation": "0.11.6",
36
+ "@lwrjs/shared-utils": "0.11.6",
37
37
  "lru-cache": "^10.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@lwrjs/types": "0.11.4"
40
+ "@lwrjs/types": "0.11.6"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=16.0.0"
44
44
  },
45
- "gitHead": "5528cfc12174d4800ff42db1691d14c5d194f7d6"
45
+ "gitHead": "415e25c05b4b1a0356fb89801f1242e8f73143e3"
46
46
  }