@lwrjs/app-service 0.6.0-alpha.9 → 0.6.2

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,17 +92,16 @@ 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
- if (globalThis.performance) {
103
- globalThis.performance.measure('${import_shared_utils.ON_APP_LOAD}');
104
- }
105
105
  return import(rootSpecifier).then(({default: Ctor}) => {
106
106
  init([[element, Ctor]]);
107
107
  });
@@ -110,9 +110,8 @@ Promise.all(rootComponents.map(async (rootSpecifier) => {
110
110
  isESM && options.hmrEnabled && `
111
111
  // HMR related initialization
112
112
  const viewMetadata = globalThis._lwrRuntimeDebug.viewMetadata;
113
- const hmrEndpoint = globalThis.LWR.endpoints.uris.hmr;
113
+ const hmrEndpoint = clientBootstrapConfig.endpoints.uris.hmr;
114
114
  initHMR(hmrEndpoint, viewMetadata);`,
115
- isESM && `delete globalThis.LWR;`,
116
115
  isAMD && `
117
116
  globalThis.LWR = Object.freeze({
118
117
  define: globalThis.LWR.define,
@@ -1,4 +1,4 @@
1
- import { DEFAULT_LWR_BOOTSTRAP_CONFIG, ON_APP_LOAD } from '@lwrjs/shared-utils';
1
+ import { DEFAULT_LWR_BOOTSTRAP_CONFIG } from '@lwrjs/shared-utils';
2
2
  function getDefaultImportName(service) {
3
3
  return `loaderService_${service.replace(/\//gi, '_').replace(/@/gi, '')}`;
4
4
  }
@@ -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,19 +92,20 @@ 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
- if (globalThis.performance) {
103
- globalThis.performance.measure('${ON_APP_LOAD}');
104
- }
105
109
  return import(rootSpecifier).then(({default: Ctor}) => {
106
110
  init([[element, Ctor]]);
107
111
  });
@@ -112,10 +116,9 @@ Promise.all(rootComponents.map(async (rootSpecifier) => {
112
116
  `
113
117
  // HMR related initialization
114
118
  const viewMetadata = globalThis._lwrRuntimeDebug.viewMetadata;
115
- const hmrEndpoint = globalThis.LWR.endpoints.uris.hmr;
119
+ const hmrEndpoint = clientBootstrapConfig.endpoints.uris.hmr;
116
120
  initHMR(hmrEndpoint, viewMetadata);`,
117
- // LAST TASK: Cleanup globalThis.LWR in ESM (the shim does this for AMD)
118
- isESM && `delete globalThis.LWR;`,
121
+ // TODO: can be removed following https://github.com/salesforce/lwr/issues/1092
119
122
  // LAST TASK: Cleanup globalThis.LWR in AMD
120
123
  isAMD &&
121
124
  `
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.6.0-alpha.9",
7
+ "version": "0.6.2",
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.9",
37
- "@lwrjs/shared-utils": "0.6.0-alpha.9"
36
+ "@lwrjs/diagnostics": "0.6.2",
37
+ "@lwrjs/shared-utils": "0.6.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@lwrjs/types": "0.6.0-alpha.9"
40
+ "@lwrjs/types": "0.6.2"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=14.15.4 <17"
44
44
  },
45
- "gitHead": "9cb371a5d01ef345660138a48fe0b3f0119d0799"
45
+ "gitHead": "ef85bdc48adde58b7c648561d67acbb408bbe189"
46
46
  }