@lwrjs/app-service 0.6.0-alpha.10 → 0.6.0-alpha.14

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.
@@ -81,6 +81,7 @@ function createAppRouteViewBootstrapModule(route, options, lockerConfig) {
81
81
  const bootstrapModule = experimentalSSR ? "lwr/initSsr" : "lwr/init";
82
82
  return [
83
83
  "/* This module is generated */",
84
+ isESM && `import { getClientBootstrapConfig } from 'lwr/preInit';`,
84
85
  syntheticShadow && `import '@lwc/synthetic-shadow';`,
85
86
  services && services.length && `import { services } from '${serviceApiModule}';`,
86
87
  servicesSource,
@@ -91,12 +92,14 @@ function createAppRouteViewBootstrapModule(route, options, lockerConfig) {
91
92
  import { registerLockerDefine } from 'lwr/lockerDefine';
92
93
  registerLockerDefine(${JSON.stringify(lockerConfig.trustedComponents)});
93
94
  `,
95
+ isESM && `const clientBootstrapConfig = getClientBootstrapConfig()`,
96
+ isAMD && `const clientBootstrapConfig = globalThis.LWR`,
94
97
  isESM && `
95
- const { imports, index, importMappings, endpoints } = globalThis.LWR;
98
+ const { imports, index, importMappings, endpoints } = clientBootstrapConfig;
96
99
  esmLoaderInit({ imports, index, importMappings, endpoints });`,
97
100
  `
98
101
  // initialize additional non-configured root components
99
- const { rootComponents } = globalThis.LWR;
102
+ const { rootComponents } = clientBootstrapConfig;
100
103
  Promise.all(rootComponents.map(async (rootSpecifier) => {
101
104
  const element = toKebabCase(rootSpecifier);
102
105
  if (globalThis.performance) {
@@ -110,9 +113,8 @@ Promise.all(rootComponents.map(async (rootSpecifier) => {
110
113
  isESM && options.hmrEnabled && `
111
114
  // HMR related initialization
112
115
  const viewMetadata = globalThis._lwrRuntimeDebug.viewMetadata;
113
- const hmrEndpoint = globalThis.LWR.endpoints.uris.hmr;
116
+ const hmrEndpoint = clientBootstrapConfig.endpoints.uris.hmr;
114
117
  initHMR(hmrEndpoint, viewMetadata);`,
115
- isESM && `delete globalThis.LWR;`,
116
118
  isAMD && `
117
119
  globalThis.LWR = Object.freeze({
118
120
  define: globalThis.LWR.define,
@@ -68,9 +68,12 @@ export function createAppRouteViewBootstrapModule(route, options, lockerConfig)
68
68
  const bootstrapModule = experimentalSSR ? 'lwr/initSsr' : 'lwr/init';
69
69
  return [
70
70
  '/* This module is generated */',
71
+ // pre app initialization step
72
+ // TODO: enable for AMD once https://github.com/salesforce/lwr/issues/1087 is implemented
73
+ isESM && `import { getClientBootstrapConfig } from 'lwr/preInit';`,
71
74
  // conditional shadow
72
75
  syntheticShadow && `import '@lwc/synthetic-shadow';`,
73
- // Import loader services
76
+ // Import bootstrap services
74
77
  services && services.length && `import { services } from '${serviceApiModule}';`,
75
78
  // import and register the configured services
76
79
  servicesSource,
@@ -89,14 +92,18 @@ export function createAppRouteViewBootstrapModule(route, options, lockerConfig)
89
92
  import { registerLockerDefine } from 'lwr/lockerDefine';
90
93
  registerLockerDefine(${JSON.stringify(lockerConfig.trustedComponents)});
91
94
  `,
95
+ // grab client bootstrap config
96
+ isESM && `const clientBootstrapConfig = getClientBootstrapConfig()`,
97
+ // TODO: https://github.com/salesforce/lwr/issues/1087
98
+ isAMD && `const clientBootstrapConfig = globalThis.LWR`,
92
99
  // Initialize the ESM loader with the Client Bootstrap Config
93
100
  isESM &&
94
101
  `
95
- const { imports, index, importMappings, endpoints } = globalThis.LWR;
102
+ const { imports, index, importMappings, endpoints } = clientBootstrapConfig;
96
103
  esmLoaderInit({ imports, index, importMappings, endpoints });`,
97
104
  `
98
105
  // initialize additional non-configured root components
99
- const { rootComponents } = globalThis.LWR;
106
+ const { rootComponents } = clientBootstrapConfig;
100
107
  Promise.all(rootComponents.map(async (rootSpecifier) => {
101
108
  const element = toKebabCase(rootSpecifier);
102
109
  if (globalThis.performance) {
@@ -112,10 +119,9 @@ Promise.all(rootComponents.map(async (rootSpecifier) => {
112
119
  `
113
120
  // HMR related initialization
114
121
  const viewMetadata = globalThis._lwrRuntimeDebug.viewMetadata;
115
- const hmrEndpoint = globalThis.LWR.endpoints.uris.hmr;
122
+ const hmrEndpoint = clientBootstrapConfig.endpoints.uris.hmr;
116
123
  initHMR(hmrEndpoint, viewMetadata);`,
117
- // LAST TASK: Cleanup globalThis.LWR in ESM (the shim does this for AMD)
118
- isESM && `delete globalThis.LWR;`,
124
+ // TODO: can be removed following https://github.com/salesforce/lwr/issues/1092
119
125
  // LAST TASK: Cleanup globalThis.LWR in AMD
120
126
  isAMD &&
121
127
  `
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.6.0-alpha.10",
7
+ "version": "0.6.0-alpha.14",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -33,14 +33,14 @@
33
33
  "build/**/*.d.ts"
34
34
  ],
35
35
  "dependencies": {
36
- "@lwrjs/diagnostics": "0.6.0-alpha.10",
37
- "@lwrjs/shared-utils": "0.6.0-alpha.10"
36
+ "@lwrjs/diagnostics": "0.6.0-alpha.14",
37
+ "@lwrjs/shared-utils": "0.6.0-alpha.14"
38
38
  },
39
39
  "devDependencies": {
40
- "@lwrjs/types": "0.6.0-alpha.10"
40
+ "@lwrjs/types": "0.6.0-alpha.14"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=14.15.4 <17"
44
44
  },
45
- "gitHead": "85914e17d6214748489426252dd8fa41c8938b8f"
45
+ "gitHead": "2850ceddcf17cdc561abbdbeb465edc5d5391cfa"
46
46
  }