@lwrjs/view-registry 0.8.0-alpha.2 → 0.8.0-alpha.5

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.
@@ -58,6 +58,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
58
58
  const rootComponents = [];
59
59
  const requiredAmdModules = [];
60
60
  const preloadAmdModules = [];
61
+ const isSSR = view.bootstrap?.experimentalSSR;
61
62
  if (isAMD) {
62
63
  const shimBundle = !bundle ? "lwr-loader-shim-legacy.js" : debug || minify === false ? "lwr-loader-shim-legacy.bundle.js" : "lwr-loader-shim-legacy.bundle.min.js";
63
64
  const def = await resourceRegistry.getResource({specifier: shimBundle, version}, runtimeEnvironment, runtimeParams);
@@ -74,14 +75,17 @@ async function getHtmlResources(view, viewParams, resourceContext) {
74
75
  requiredResources.push(await (0, import_utils.getModuleResource)({
75
76
  specifier: "lwr/loaderLegacy",
76
77
  version
77
- }, moduleRegistry, runtimeEnvironment, runtimeParams));
78
+ }, runtimeEnvironment, {
79
+ isPreload: false,
80
+ isSSR
81
+ }, moduleRegistry, runtimeParams));
78
82
  }
79
83
  }
80
84
  const depth = isAMD ? {static: import_shared_utils.GraphDepth.ALL, dynamic: 1} : {static: import_shared_utils.GraphDepth.NONE, dynamic: 0};
81
85
  const bootstrapModuleGraph = await (0, import_shared_utils.getModuleGraphs)(bootstrapSpecifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams, visitedCache);
82
86
  const versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
83
87
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
84
- moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment));
88
+ moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment, {isPreload: false, isSSR}));
85
89
  if (isAMD) {
86
90
  requiredAmdModules.push(versionedSpecifier);
87
91
  imports[versionedSpecifier] = uri;
@@ -89,7 +93,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
89
93
  const uri2 = bootstrapModuleGraph.uriMap[staticDep];
90
94
  imports[staticDep] = uri2;
91
95
  if (services && services.length) {
92
- moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, true));
96
+ moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, {isPreload: true, isSSR}));
93
97
  requiredAmdModules.push(staticDep);
94
98
  }
95
99
  }
@@ -102,7 +106,6 @@ async function getHtmlResources(view, viewParams, resourceContext) {
102
106
  }
103
107
  }
104
108
  }
105
- const isSSR = view.bootstrap?.experimentalSSR;
106
109
  const customElementsRecords = [];
107
110
  const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
108
111
  await Promise.all(flattenedElements.map(async ({tagName: element, props}) => {
@@ -110,7 +113,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
110
113
  customElementsRecords.push({elementName: element, flatGraph: graph});
111
114
  const specifier = graph.graphs[0].specifier;
112
115
  const uri2 = graph.uriMap[specifier];
113
- moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, true));
116
+ moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, {isPreload: true, isSSR}));
114
117
  rootComponents.push(specifier);
115
118
  imports[specifier] = uri2;
116
119
  if (isAMD) {
@@ -58,6 +58,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
58
58
  const rootComponents = [];
59
59
  const requiredAmdModules = [];
60
60
  const preloadAmdModules = [];
61
+ const isSSR = view.bootstrap?.experimentalSSR;
61
62
  if (isAMD) {
62
63
  const shimBundle = !bundle ? "lwr-loader-shim.js" : debug || minify === false ? "lwr-loader-shim.bundle.js" : "lwr-loader-shim.bundle.min.js";
63
64
  const def = await resourceRegistry.getResource({specifier: shimBundle, version}, runtimeEnvironment, runtimeParams);
@@ -74,14 +75,16 @@ async function getHtmlResources(view, viewParams, resourceContext) {
74
75
  requiredResources.push(await (0, import_utils.getModuleResource)({
75
76
  specifier: "lwr/loader",
76
77
  version
77
- }, moduleRegistry, runtimeEnvironment, runtimeParams));
78
+ }, runtimeEnvironment, {
79
+ isSSR
80
+ }, moduleRegistry, runtimeParams));
78
81
  }
79
82
  }
80
83
  const depth = isAMD ? {static: import_shared_utils.GraphDepth.ALL, dynamic: 1} : {static: import_shared_utils.GraphDepth.NONE, dynamic: 1};
81
84
  const bootstrapModuleGraph = await (0, import_shared_utils.getModuleGraphs)(bootstrapSpecifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams, visitedCache);
82
85
  const versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
83
86
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
84
- moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment));
87
+ moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment, {isPreload: false, isSSR}));
85
88
  if (isAMD) {
86
89
  requiredAmdModules.push(versionedSpecifier);
87
90
  imports[versionedSpecifier] = uri;
@@ -89,7 +92,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
89
92
  const uri2 = bootstrapModuleGraph.uriMap[staticDep];
90
93
  imports[staticDep] = uri2;
91
94
  if (services && services.length) {
92
- moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, true));
95
+ moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, {isPreload: true, isSSR}));
93
96
  requiredAmdModules.push(staticDep);
94
97
  }
95
98
  }
@@ -103,7 +106,6 @@ async function getHtmlResources(view, viewParams, resourceContext) {
103
106
  }
104
107
  }
105
108
  let importMetadata = await (0, import_shared_utils.toImportMetadata)(bootstrapModuleGraph, {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams);
106
- const isSSR = view.bootstrap?.experimentalSSR;
107
109
  const customElementsRecords = [];
108
110
  const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
109
111
  await Promise.all(flattenedElements.map(async ({tagName: element, props}) => {
@@ -111,7 +113,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
111
113
  customElementsRecords.push({elementName: element, flatGraph: graph});
112
114
  const specifier = graph.graphs[0].specifier;
113
115
  const uri2 = graph.uriMap[specifier];
114
- moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, true));
116
+ moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, {isPreload: true, isSSR}));
115
117
  rootComponents.push(specifier);
116
118
  imports[specifier] = uri2;
117
119
  if (isAMD) {
@@ -53,9 +53,14 @@ function streamToString(stream) {
53
53
  function generateExternalStyle(src) {
54
54
  return `<link rel="stylesheet" href="${src}">`;
55
55
  }
56
- function generateExternalScript(type = "application/javascript", src, async) {
57
- const asyncStr = async ? " async" : "";
58
- return `<script type="${type}"${asyncStr} src="${src}"></script>`;
56
+ function generateExternalScript(type = "application/javascript", src, async, defer) {
57
+ let scriptLoadOrder = "";
58
+ if (defer) {
59
+ scriptLoadOrder = " defer";
60
+ } else if (async) {
61
+ scriptLoadOrder = " async";
62
+ }
63
+ return `<script type="${type}"${scriptLoadOrder} src="${src}"></script>`;
59
64
  }
60
65
  function generateLinkPreloadTag({href, type}) {
61
66
  if (type === "module") {
@@ -64,13 +69,13 @@ function generateLinkPreloadTag({href, type}) {
64
69
  return `<link rel="preload" href="${href}" type="${type}" />`;
65
70
  }
66
71
  }
67
- function generateExternalTag({type, src = "", async, isPreload}) {
72
+ function generateExternalTag({type, src = "", async, defer, isPreload}) {
68
73
  if (isPreload) {
69
74
  return generateLinkPreloadTag({href: src, type});
70
75
  } else if (type === "text/css") {
71
76
  return generateExternalStyle(src);
72
77
  } else {
73
- return generateExternalScript(type, src, async);
78
+ return generateExternalScript(type, src, async, defer);
74
79
  }
75
80
  }
76
81
  async function generateInlineTag({specifier, type, content, stream, nonce}) {
@@ -224,22 +229,26 @@ async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEnvironme
224
229
  }
225
230
  };
226
231
  }
227
- async function getModuleResource(moduleId, moduleRegistry, runtimeEnvironment, runtimeParams, isPreload) {
228
- const moduleUri = await moduleRegistry.resolveModuleUri(moduleId, runtimeEnvironment, runtimeParams);
232
+ async function getModuleResource(moduleId, runtimeEnvironment, moduleResouceMeta, moduleRegistry, runtimeParams) {
229
233
  const {format} = runtimeEnvironment;
234
+ const {isSSR = false, isPreload = false} = moduleResouceMeta;
235
+ const moduleUri = await moduleRegistry.resolveModuleUri(moduleId, runtimeEnvironment, runtimeParams);
230
236
  return {
231
237
  src: moduleUri,
232
238
  type: format === "amd" ? "application/javascript" : "module",
233
- async: isPreload,
239
+ async: !isSSR && isPreload,
240
+ defer: isSSR,
234
241
  isPreload: format !== "amd" && isPreload
235
242
  };
236
243
  }
237
- function getModuleResourceByUri(moduleUri, runtimeEnvironment, isPreload) {
244
+ function getModuleResourceByUri(uri, runtimeEnvironment, moduleResouceMeta) {
245
+ const {isSSR = false, isPreload = false} = moduleResouceMeta;
238
246
  const {format} = runtimeEnvironment;
239
247
  return {
240
- src: moduleUri,
248
+ src: uri,
241
249
  type: format === "amd" ? "application/javascript" : "module",
242
- async: isPreload,
250
+ async: !isSSR && isPreload,
251
+ defer: isSSR,
243
252
  isPreload: format !== "amd" && isPreload
244
253
  };
245
254
  }
@@ -39,6 +39,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
39
39
  const requiredAmdModules = [];
40
40
  // Collection of modules that will be loaded in the view
41
41
  const preloadAmdModules = [];
42
+ // Determine if server side rendering view modules
43
+ const isSSR = view.bootstrap?.experimentalSSR;
42
44
  // ------ AMD Required module resources
43
45
  if (isAMD) {
44
46
  // Keep shim format in sync with view_bootstrap.ts
@@ -64,7 +66,10 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
64
66
  requiredResources.push(await getModuleResource({
65
67
  specifier: 'lwr/loaderLegacy',
66
68
  version,
67
- }, moduleRegistry, runtimeEnvironment, runtimeParams));
69
+ }, runtimeEnvironment, {
70
+ isPreload: false,
71
+ isSSR,
72
+ }, moduleRegistry, runtimeParams));
68
73
  }
69
74
  }
70
75
  // ------- Application Bootstrap module
@@ -78,7 +83,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
78
83
  // ADD bootstrap module uri as a script resource
79
84
  const versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
80
85
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
81
- moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment));
86
+ moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: false, isSSR }));
82
87
  if (isAMD) {
83
88
  // ADD bootstrap module as required
84
89
  requiredAmdModules.push(versionedSpecifier);
@@ -92,7 +97,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
92
97
  // ADD bootstrap module static deps to requiredAmdModules if services, otherwise preloadModules
93
98
  if (services && services.length) {
94
99
  // get the graphs for the bs static deps
95
- moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, true));
100
+ moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: true, isSSR }));
96
101
  requiredAmdModules.push(staticDep);
97
102
  }
98
103
  }
@@ -108,7 +113,6 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
108
113
  }
109
114
  }
110
115
  // ------- View related custom element moduleResources
111
- const isSSR = view.bootstrap?.experimentalSSR;
112
116
  const customElementsRecords = [];
113
117
  const flattenedElements = flattenCustomElements(customElements, isSSR);
114
118
  await Promise.all(flattenedElements.map(async ({ tagName: element, props }) => {
@@ -118,7 +122,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
118
122
  // PRELOAD custom element static deps as link resource
119
123
  const specifier = graph.graphs[0].specifier;
120
124
  const uri = graph.uriMap[specifier];
121
- moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, true));
125
+ moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: true, isSSR }));
122
126
  // ADD register custom elements as a uri addressable rootComponents
123
127
  rootComponents.push(specifier);
124
128
  imports[specifier] = uri;
@@ -39,6 +39,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
39
39
  const requiredAmdModules = [];
40
40
  // Collection of modules that will be loaded in the view
41
41
  const preloadAmdModules = [];
42
+ // Determine if server side rendering view modules
43
+ const isSSR = view.bootstrap?.experimentalSSR;
42
44
  // ------ AMD Required module resources
43
45
  if (isAMD) {
44
46
  // Keep shim format in sync with legacy_view_bootstrap.ts
@@ -64,7 +66,9 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
64
66
  requiredResources.push(await getModuleResource({
65
67
  specifier: 'lwr/loader',
66
68
  version,
67
- }, moduleRegistry, runtimeEnvironment, runtimeParams));
69
+ }, runtimeEnvironment, {
70
+ isSSR,
71
+ }, moduleRegistry, runtimeParams));
68
72
  }
69
73
  }
70
74
  // ------- Application Bootstrap module
@@ -77,7 +81,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
77
81
  // ADD bootstrap module uri as a script resource
78
82
  const versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
79
83
  const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
80
- moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment));
84
+ moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: false, isSSR }));
81
85
  if (isAMD) {
82
86
  // ADD bootstrap module as required
83
87
  requiredAmdModules.push(versionedSpecifier);
@@ -91,7 +95,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
91
95
  // ADD bootstrap module static deps to requiredAmdModules if services, otherwise preloadModules
92
96
  if (services && services.length) {
93
97
  // get the graphs for the bs static deps
94
- moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, true));
98
+ moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: true, isSSR }));
95
99
  requiredAmdModules.push(staticDep);
96
100
  }
97
101
  }
@@ -108,7 +112,6 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
108
112
  }
109
113
  let importMetadata = await toImportMetadata(bootstrapModuleGraph, { imports: {}, index: {} }, moduleRegistry, runtimeEnvironment, runtimeParams);
110
114
  // ------- View related custom element moduleResources
111
- const isSSR = view.bootstrap?.experimentalSSR;
112
115
  const customElementsRecords = [];
113
116
  const flattenedElements = flattenCustomElements(customElements, isSSR);
114
117
  await Promise.all(flattenedElements.map(async ({ tagName: element, props }) => {
@@ -118,7 +121,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
118
121
  // PRELOAD custom element static deps as link resource
119
122
  const specifier = graph.graphs[0].specifier;
120
123
  const uri = graph.uriMap[specifier];
121
- moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, true));
124
+ moduleResources.push(getModuleResourceByUri(uri, runtimeEnvironment, { isPreload: true, isSSR }));
122
125
  // ADD register custom elements as a uri addressable rootComponents
123
126
  rootComponents.push(specifier);
124
127
  imports[specifier] = uri;
@@ -1,4 +1,4 @@
1
- import { NormalizedRenderingResult, RenderingResult, ResourceDefinition, AssetReference, RenderedAssetReference, RenderOptions, ModuleId, ViewPageContext, JsonCompatible } from '@lwrjs/types';
1
+ import { NormalizedRenderingResult, RenderingResult, ResourceDefinition, AssetReference, RenderedAssetReference, RenderOptions, ModuleId, ViewModuleResourceContext, ViewPageContext, JsonCompatible } from '@lwrjs/types';
2
2
  import { PublicModuleRegistry, RuntimeEnvironment, RuntimeParams, ModuleJson, RouteHandlerViewResponse, ViewResponse, RouteHandlerFunction, LwrRoute, LwrErrorRoute, ViewRequest, LinkedViewDefinition, ModuleRegistry } from 'packages/@lwrjs/types/src';
3
3
  export declare type HTMLResource = Partial<ResourceDefinition>;
4
4
  export declare function generateHtmlTag(definition: HTMLResource): Promise<string>;
@@ -18,8 +18,8 @@ interface RouteHandlerContext {
18
18
  */
19
19
  export declare function getRouteHandler(path: string, { cacheDir, rootDir }: RouteHandlerContext): Promise<RouteHandlerFunction>;
20
20
  export declare function toJsonFormat(viewRequest: ViewRequest, viewDefinition: LinkedViewDefinition, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams, moduleRegistry: ModuleRegistry): Promise<ViewResponse>;
21
- export declare function getModuleResource(moduleId: Pick<ModuleId, 'specifier' | 'version'>, moduleRegistry: ModuleRegistry, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams, isPreload?: boolean): Promise<ResourceDefinition>;
22
- export declare function getModuleResourceByUri(moduleUri: string, runtimeEnvironment: RuntimeEnvironment, isPreload?: boolean): ResourceDefinition;
21
+ export declare function getModuleResource(moduleId: Pick<ModuleId, 'specifier' | 'version'>, runtimeEnvironment: RuntimeEnvironment, moduleResouceMeta: ViewModuleResourceContext, moduleRegistry: ModuleRegistry, runtimeParams?: RuntimeParams): Promise<ResourceDefinition>;
22
+ export declare function getModuleResourceByUri(uri: string, runtimeEnvironment: RuntimeEnvironment, moduleResouceMeta: ViewModuleResourceContext): ResourceDefinition;
23
23
  export declare function createJsonModule(specifier: string, moduleRegistry: PublicModuleRegistry, environment: RuntimeEnvironment, params?: RuntimeParams): Promise<ModuleJson>;
24
24
  export {};
25
25
  //# sourceMappingURL=utils.d.ts.map
package/build/es/utils.js CHANGED
@@ -15,9 +15,15 @@ function streamToString(stream) {
15
15
  function generateExternalStyle(src) {
16
16
  return `<link rel="stylesheet" href="${src}">`;
17
17
  }
18
- function generateExternalScript(type = 'application/javascript', src, async) {
19
- const asyncStr = async ? ' async' : '';
20
- return `<script type="${type}"${asyncStr} src="${src}"></script>`;
18
+ function generateExternalScript(type = 'application/javascript', src, async, defer) {
19
+ let scriptLoadOrder = '';
20
+ if (defer) {
21
+ scriptLoadOrder = ' defer';
22
+ }
23
+ else if (async) {
24
+ scriptLoadOrder = ' async';
25
+ }
26
+ return `<script type="${type}"${scriptLoadOrder} src="${src}"></script>`;
21
27
  }
22
28
  function generateLinkPreloadTag({ href, type }) {
23
29
  if (type === 'module') {
@@ -27,7 +33,7 @@ function generateLinkPreloadTag({ href, type }) {
27
33
  return `<link rel="preload" href="${href}" type="${type}" />`;
28
34
  }
29
35
  }
30
- function generateExternalTag({ type, src = '', async, isPreload }) {
36
+ function generateExternalTag({ type, src = '', async, defer, isPreload }) {
31
37
  if (isPreload) {
32
38
  return generateLinkPreloadTag({ href: src, type: type });
33
39
  }
@@ -35,7 +41,7 @@ function generateExternalTag({ type, src = '', async, isPreload }) {
35
41
  return generateExternalStyle(src);
36
42
  }
37
43
  else {
38
- return generateExternalScript(type, src, async);
44
+ return generateExternalScript(type, src, async, defer);
39
45
  }
40
46
  }
41
47
  async function generateInlineTag({ specifier, type, content, stream, nonce }) {
@@ -207,24 +213,28 @@ export async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEn
207
213
  },
208
214
  };
209
215
  }
210
- export async function getModuleResource(moduleId, moduleRegistry, runtimeEnvironment, runtimeParams, isPreload) {
211
- const moduleUri = await moduleRegistry.resolveModuleUri(moduleId, runtimeEnvironment, runtimeParams);
216
+ export async function getModuleResource(moduleId, runtimeEnvironment, moduleResouceMeta, moduleRegistry, runtimeParams) {
212
217
  const { format } = runtimeEnvironment;
218
+ const { isSSR = false, isPreload = false } = moduleResouceMeta;
219
+ const moduleUri = await moduleRegistry.resolveModuleUri(moduleId, runtimeEnvironment, runtimeParams);
213
220
  return {
214
221
  src: moduleUri,
215
222
  type: format === 'amd' ? 'application/javascript' : 'module',
216
- async: isPreload,
223
+ async: !isSSR && isPreload,
224
+ defer: isSSR,
217
225
  // only use link preload for ESM for compat reasons.
218
226
  // AMD should use regular script tags for preloading
219
227
  isPreload: format !== 'amd' && isPreload,
220
228
  };
221
229
  }
222
- export function getModuleResourceByUri(moduleUri, runtimeEnvironment, isPreload) {
230
+ export function getModuleResourceByUri(uri, runtimeEnvironment, moduleResouceMeta) {
231
+ const { isSSR = false, isPreload = false } = moduleResouceMeta;
223
232
  const { format } = runtimeEnvironment;
224
233
  return {
225
- src: moduleUri,
234
+ src: uri,
226
235
  type: format === 'amd' ? 'application/javascript' : 'module',
227
- async: isPreload,
236
+ async: !isSSR && isPreload,
237
+ defer: isSSR,
228
238
  // only use link preload for ESM for compat reasons.
229
239
  // AMD should use regular script tags for preloading
230
240
  isPreload: format !== 'amd' && isPreload,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.8.0-alpha.2",
7
+ "version": "0.8.0-alpha.5",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,15 +30,15 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@lwrjs/app-service": "0.8.0-alpha.2",
34
- "@lwrjs/diagnostics": "0.8.0-alpha.2",
35
- "@lwrjs/shared-utils": "0.8.0-alpha.2"
33
+ "@lwrjs/app-service": "0.8.0-alpha.5",
34
+ "@lwrjs/diagnostics": "0.8.0-alpha.5",
35
+ "@lwrjs/shared-utils": "0.8.0-alpha.5"
36
36
  },
37
37
  "devDependencies": {
38
- "@lwrjs/types": "0.8.0-alpha.2"
38
+ "@lwrjs/types": "0.8.0-alpha.5"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=14.15.4 <19"
42
42
  },
43
- "gitHead": "44bee038acb30418870678d886e3ded4a6afecf0"
43
+ "gitHead": "bc2eed0c7a5a5f9ecbbd335bf896e6d6c5076c19"
44
44
  }