@lwrjs/view-registry 0.11.13 → 0.11.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.
@@ -46,11 +46,21 @@ async function getHtmlResources(view, viewParams, resourceContext) {
46
46
  const version = lwrVersion;
47
47
  const isAMD = format === "amd";
48
48
  const {bundleConfig} = resourceContext;
49
- const {external = {}} = bundleConfig;
49
+ const {external = {}, exclude = []} = bundleConfig;
50
50
  const groups = isAMD ? bundleConfig.groups || {} : {};
51
- const isExternal = function(rawSpecifier) {
51
+ const getPreloadUri = function(rawSpecifier, uriMap) {
52
52
  const {specifier} = (0, import_shared_utils.explodeSpecifier)(rawSpecifier);
53
- return Object.keys(external).some((e) => specifier === e);
53
+ if (Object.keys(external).some((e) => specifier === e))
54
+ return;
55
+ const uri = uriMap[rawSpecifier];
56
+ if (!uri && (exclude.includes(specifier) || (0, import_shared_utils.isGroupie)(specifier, groups))) {
57
+ import_diagnostics.logger.warn({
58
+ label: "view-registry",
59
+ message: `Skipping preload of unknown static import: ${rawSpecifier}`
60
+ });
61
+ return;
62
+ }
63
+ return uri;
54
64
  };
55
65
  const {
56
66
  id: appName,
@@ -127,8 +137,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
127
137
  }
128
138
  moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment, {isPreload: false, isSSR}));
129
139
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
130
- if (!isExternal(depSpecifier)) {
131
- const uri2 = bootstrapModuleGraph.uriMap[depSpecifier];
140
+ const uri2 = getPreloadUri(depSpecifier, bootstrapModuleGraph.uriMap);
141
+ if (uri2) {
132
142
  (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, groups, viewPreloads);
133
143
  }
134
144
  }
@@ -169,8 +179,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
169
179
  (0, import_preload_utils.setPreloadModulesMeta)(specifier, uri, groups, viewPreloads);
170
180
  if (bundle) {
171
181
  for (const depSpecifier of graph.graphs[0].static) {
172
- if (!isExternal(depSpecifier)) {
173
- const uri2 = graph.uriMap[depSpecifier];
182
+ const uri2 = getPreloadUri(depSpecifier, graph.uriMap);
183
+ if (uri2) {
174
184
  (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, groups, viewPreloads);
175
185
  }
176
186
  }
@@ -48,11 +48,21 @@ async function getHtmlResources(view, viewParams, resourceContext) {
48
48
  const isAMD = format === "amd";
49
49
  const depth = isAMD ? {static: import_shared_utils.GraphDepth.ALL, dynamic: 1} : {static: import_shared_utils.GraphDepth.NONE, dynamic: 1};
50
50
  const {bundleConfig} = resourceContext;
51
- const {external = {}} = bundleConfig;
51
+ const {external = {}, exclude = []} = bundleConfig;
52
52
  const groups = isAMD ? bundleConfig.groups || {} : {};
53
- const isExternal = function(rawSpecifier) {
53
+ const getPreloadUri = function(rawSpecifier, uriMap) {
54
54
  const {specifier} = (0, import_shared_utils.explodeSpecifier)(rawSpecifier);
55
- return Object.keys(external).some((e) => specifier === e);
55
+ if (Object.keys(external).some((e) => specifier === e))
56
+ return;
57
+ const uri = uriMap[rawSpecifier];
58
+ if (!uri && (exclude.includes(specifier) || (0, import_shared_utils.isGroupie)(specifier, groups))) {
59
+ import_diagnostics.logger.warn({
60
+ label: "view-registry",
61
+ message: `Skipping preload of unknown static import: ${rawSpecifier}`
62
+ });
63
+ return;
64
+ }
65
+ return uri;
56
66
  };
57
67
  const {
58
68
  id: appName,
@@ -118,8 +128,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
118
128
  }
119
129
  moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment, {isPreload: false, isSSR}));
120
130
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
121
- if (!isExternal(depSpecifier)) {
122
- const uri2 = bootstrapModuleGraph.uriMap[depSpecifier];
131
+ const uri2 = getPreloadUri(depSpecifier, bootstrapModuleGraph.uriMap);
132
+ if (uri2) {
123
133
  (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, groups, viewPreloads);
124
134
  }
125
135
  }
@@ -161,8 +171,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
161
171
  (0, import_preload_utils.setPreloadModulesMeta)(specifier, uri, groups, viewPreloads);
162
172
  if (bundle) {
163
173
  for (const depSpecifier of graph.graphs[0].static) {
164
- if (!isExternal(depSpecifier)) {
165
- const uri2 = graph.uriMap[depSpecifier];
174
+ const uri2 = getPreloadUri(depSpecifier, graph.uriMap);
175
+ if (uri2) {
166
176
  (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, groups, viewPreloads);
167
177
  }
168
178
  }
@@ -1,5 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import { kebabCaseToModuleSpecifier, getModuleGraphs, GraphDepth, getModuleUriPrefix, explodeSpecifier, isBundler, getHydrateDirective, } from '@lwrjs/shared-utils';
2
+ import { kebabCaseToModuleSpecifier, getModuleGraphs, GraphDepth, getModuleUriPrefix, explodeSpecifier, isBundler, getHydrateDirective, isGroupie, } from '@lwrjs/shared-utils';
3
3
  import { AppResourceEnum, getAppSpecifier } from '@lwrjs/app-service/identity';
4
4
  import { generateHtmlTag, getModuleResourceByUri } from '../utils.js';
5
5
  import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
@@ -11,12 +11,26 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
11
11
  const version = lwrVersion;
12
12
  const isAMD = format === 'amd';
13
13
  const { bundleConfig } = resourceContext;
14
- const { external = {} } = bundleConfig;
14
+ const { external = {}, exclude = [] } = bundleConfig;
15
15
  // Bundling groups is only supported in AMD for now
16
16
  const groups = isAMD ? bundleConfig.groups || {} : {};
17
- const isExternal = function (rawSpecifier) {
17
+ const getPreloadUri = function (rawSpecifier, uriMap) {
18
18
  const { specifier } = explodeSpecifier(rawSpecifier);
19
- return Object.keys(external).some((e) => specifier === e);
19
+ // do not preload externals; this is the app's responsibility
20
+ if (Object.keys(external).some((e) => specifier === e))
21
+ return;
22
+ const uri = uriMap[rawSpecifier];
23
+ // if there is no uri for an exclude or groupie, they've been handled via another specifier
24
+ // eg: if a bundle group has already been added to the URI map, its groups will not also be added
25
+ if (!uri && (exclude.includes(specifier) || isGroupie(specifier, groups))) {
26
+ // warn instead of throwing from setPreloadModulesMeta()
27
+ logger.warn({
28
+ label: 'view-registry',
29
+ message: `Skipping preload of unknown static import: ${rawSpecifier}`,
30
+ });
31
+ return;
32
+ }
33
+ return uri;
20
34
  };
21
35
  const { id: appName, bootstrap: { services, module: bootstrapModule, preloadModules = [] } = {
22
36
  services: [],
@@ -130,8 +144,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
130
144
  moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: false, isSSR }));
131
145
  // PRELOAD the bootstrap module static dependencies as preloaded script resources
132
146
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
133
- if (!isExternal(depSpecifier)) {
134
- const uri = bootstrapModuleGraph.uriMap[depSpecifier];
147
+ const uri = getPreloadUri(depSpecifier, bootstrapModuleGraph.uriMap);
148
+ if (uri) {
135
149
  setPreloadModulesMeta(depSpecifier, uri, groups, viewPreloads);
136
150
  }
137
151
  }
@@ -186,8 +200,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
186
200
  // PRELOAD custom element static deps as link resources when bundling is ON
187
201
  if (bundle) {
188
202
  for (const depSpecifier of graph.graphs[0].static) {
189
- if (!isExternal(depSpecifier)) {
190
- const uri = graph.uriMap[depSpecifier];
203
+ const uri = getPreloadUri(depSpecifier, graph.uriMap);
204
+ if (uri) {
191
205
  setPreloadModulesMeta(depSpecifier, uri, groups, viewPreloads);
192
206
  }
193
207
  }
@@ -1,5 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import { kebabCaseToModuleSpecifier, toImportMetadata, getModuleGraphs, getMappingUriPrefix, GraphDepth, explodeSpecifier, isBundler, getHydrateDirective, } from '@lwrjs/shared-utils';
2
+ import { kebabCaseToModuleSpecifier, toImportMetadata, getModuleGraphs, getMappingUriPrefix, GraphDepth, explodeSpecifier, isBundler, getHydrateDirective, isGroupie, } from '@lwrjs/shared-utils';
3
3
  import { AppResourceEnum, getAppSpecifier } from '@lwrjs/app-service/identity';
4
4
  import { generateHtmlTag, getModuleResourceByUri } from '../utils.js';
5
5
  import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
@@ -15,12 +15,23 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
15
15
  ? { static: GraphDepth.ALL, dynamic: 1 }
16
16
  : { static: GraphDepth.NONE, dynamic: 1 };
17
17
  const { bundleConfig } = resourceContext;
18
- const { external = {} } = bundleConfig;
18
+ const { external = {}, exclude = [] } = bundleConfig;
19
19
  // Bundling groups is only supported in AMD for now
20
20
  const groups = isAMD ? bundleConfig.groups || {} : {};
21
- const isExternal = function (rawSpecifier) {
21
+ const getPreloadUri = function (rawSpecifier, uriMap) {
22
22
  const { specifier } = explodeSpecifier(rawSpecifier);
23
- return Object.keys(external).some((e) => specifier === e);
23
+ if (Object.keys(external).some((e) => specifier === e))
24
+ return;
25
+ const uri = uriMap[rawSpecifier];
26
+ if (!uri && (exclude.includes(specifier) || isGroupie(specifier, groups))) {
27
+ // warn instead of throwing from setPreloadModulesMeta()
28
+ logger.warn({
29
+ label: 'view-registry',
30
+ message: `Skipping preload of unknown static import: ${rawSpecifier}`,
31
+ });
32
+ return;
33
+ }
34
+ return uri;
24
35
  };
25
36
  const { id: appName, bootstrap: { services, module: bootstrapModule, preloadModules = [] } = {
26
37
  services: [],
@@ -114,8 +125,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
114
125
  moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: false, isSSR }));
115
126
  // PRELOAD the bootstrap module static dependencies as preloaded script resources
116
127
  for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
117
- if (!isExternal(depSpecifier)) {
118
- const uri = bootstrapModuleGraph.uriMap[depSpecifier];
128
+ const uri = getPreloadUri(depSpecifier, bootstrapModuleGraph.uriMap);
129
+ if (uri) {
119
130
  setPreloadModulesMeta(depSpecifier, uri, groups, viewPreloads);
120
131
  }
121
132
  }
@@ -172,8 +183,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
172
183
  // PRELOAD custom element static deps as link resources when bundling is ON
173
184
  if (bundle) {
174
185
  for (const depSpecifier of graph.graphs[0].static) {
175
- if (!isExternal(depSpecifier)) {
176
- const uri = graph.uriMap[depSpecifier];
186
+ const uri = getPreloadUri(depSpecifier, graph.uriMap);
187
+ if (uri) {
177
188
  setPreloadModulesMeta(depSpecifier, uri, groups, viewPreloads);
178
189
  }
179
190
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.11.13",
7
+ "version": "0.11.15",
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.13",
34
- "@lwrjs/diagnostics": "0.11.13",
35
- "@lwrjs/instrumentation": "0.11.13",
36
- "@lwrjs/shared-utils": "0.11.13",
33
+ "@lwrjs/app-service": "0.11.15",
34
+ "@lwrjs/diagnostics": "0.11.15",
35
+ "@lwrjs/instrumentation": "0.11.15",
36
+ "@lwrjs/shared-utils": "0.11.15",
37
37
  "lru-cache": "^10.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@lwrjs/types": "0.11.13"
40
+ "@lwrjs/types": "0.11.15"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=16.0.0"
44
44
  },
45
- "gitHead": "e91de40d8db1aa100c06a3075cfc4cde950dac5d"
45
+ "gitHead": "1840c91835b60bb13576b35595b199f039ba4266"
46
46
  }