@lwrjs/app-service 0.5.11-alpha.1 → 0.6.0-alpha.10

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.
@@ -73,22 +73,27 @@ function normalizeBootstrap(bootstrap) {
73
73
  }
74
74
  function createAppRouteViewBootstrapModule(route, options, lockerConfig) {
75
75
  const {bootstrap} = route;
76
- const {services, syntheticShadow} = bootstrap;
76
+ const {services, syntheticShadow, experimentalSSR} = bootstrap;
77
77
  const isAMD = options.format === "amd";
78
78
  const isESM = options.format === "esm";
79
79
  const servicesSource = bootstrap.services && createServicesSource(bootstrap.services);
80
80
  const serviceApiModule = getServiceApiModule(options.format, options.moduleLoader);
81
+ const bootstrapModule = experimentalSSR ? "lwr/initSsr" : "lwr/init";
81
82
  return [
82
83
  "/* This module is generated */",
83
84
  syntheticShadow && `import '@lwc/synthetic-shadow';`,
84
85
  services && services.length && `import { services } from '${serviceApiModule}';`,
85
86
  servicesSource,
86
87
  isESM && options.hmrEnabled && `import { initHMR } from 'lwr/hmr';`,
87
- `import { init, toKebabCase } from 'lwr/init';`,
88
+ isESM && `import { init as esmLoaderInit } from 'lwr/esmLoader';`,
89
+ `import { init, toKebabCase } from '${bootstrapModule}';`,
88
90
  isAMD && lockerConfig && lockerConfig.enabled && lockerConfig.clientOnly && `
89
91
  import { registerLockerDefine } from 'lwr/lockerDefine';
90
92
  registerLockerDefine(${JSON.stringify(lockerConfig.trustedComponents)});
91
93
  `,
94
+ isESM && `
95
+ const { imports, index, importMappings, endpoints } = globalThis.LWR;
96
+ esmLoaderInit({ imports, index, importMappings, endpoints });`,
92
97
  `
93
98
  // initialize additional non-configured root components
94
99
  const { rootComponents } = globalThis.LWR;
@@ -106,6 +111,11 @@ Promise.all(rootComponents.map(async (rootSpecifier) => {
106
111
  // HMR related initialization
107
112
  const viewMetadata = globalThis._lwrRuntimeDebug.viewMetadata;
108
113
  const hmrEndpoint = globalThis.LWR.endpoints.uris.hmr;
109
- initHMR(hmrEndpoint, viewMetadata);`
114
+ initHMR(hmrEndpoint, viewMetadata);`,
115
+ isESM && `delete globalThis.LWR;`,
116
+ isAMD && `
117
+ globalThis.LWR = Object.freeze({
118
+ define: globalThis.LWR.define,
119
+ });`
110
120
  ].filter(Boolean).join("\n");
111
121
  }
@@ -2,10 +2,10 @@ import { parsePackageSpecifier } from '@lwrjs/shared-utils';
2
2
  /*
3
3
  App Identity Taxonomy and Schema
4
4
  Application identity is an extension of the URI package identity semantics:
5
- https://rfcs.lwc.dev/rfcs/lws/0000-uri-patterns#identity-semantics
5
+ https://rfcs.lwc.dev/rfcs/lwr/0000-uri-patterns#identity-semantics
6
6
 
7
7
  Based on the App identity semantics:
8
- https://rfcs.lwc.dev/rfcs/lws/0000-lwr-bootstrap#application-definition-identifier-constraints
8
+ https://rfcs.lwc.dev/rfcs/lwr/0000-lwr-bootstrap#application-definition-identifier-constraints
9
9
 
10
10
  The combined schema for the domain of all application resource identities is described by the following
11
11
  EBNF grammar:
@@ -60,11 +60,12 @@ export function normalizeBootstrap(bootstrap) {
60
60
  */
61
61
  export function createAppRouteViewBootstrapModule(route, options, lockerConfig) {
62
62
  const { bootstrap } = route;
63
- const { services, syntheticShadow } = bootstrap;
63
+ const { services, syntheticShadow, experimentalSSR } = bootstrap;
64
64
  const isAMD = options.format === 'amd';
65
65
  const isESM = options.format === 'esm';
66
66
  const servicesSource = bootstrap.services && createServicesSource(bootstrap.services);
67
67
  const serviceApiModule = getServiceApiModule(options.format, options.moduleLoader);
68
+ const bootstrapModule = experimentalSSR ? 'lwr/initSsr' : 'lwr/init';
68
69
  return [
69
70
  '/* This module is generated */',
70
71
  // conditional shadow
@@ -75,8 +76,10 @@ export function createAppRouteViewBootstrapModule(route, options, lockerConfig)
75
76
  servicesSource,
76
77
  // HMR (ESM format only)
77
78
  isESM && options.hmrEnabled && `import { initHMR } from 'lwr/hmr';`,
79
+ // Import the ESM module initializer
80
+ isESM && `import { init as esmLoaderInit } from 'lwr/esmLoader';`,
78
81
  // init module
79
- `import { init, toKebabCase } from 'lwr/init';`,
82
+ `import { init, toKebabCase } from '${bootstrapModule}';`,
80
83
  // locker
81
84
  isAMD &&
82
85
  lockerConfig &&
@@ -86,6 +89,11 @@ export function createAppRouteViewBootstrapModule(route, options, lockerConfig)
86
89
  import { registerLockerDefine } from 'lwr/lockerDefine';
87
90
  registerLockerDefine(${JSON.stringify(lockerConfig.trustedComponents)});
88
91
  `,
92
+ // Initialize the ESM loader with the Client Bootstrap Config
93
+ isESM &&
94
+ `
95
+ const { imports, index, importMappings, endpoints } = globalThis.LWR;
96
+ esmLoaderInit({ imports, index, importMappings, endpoints });`,
89
97
  `
90
98
  // initialize additional non-configured root components
91
99
  const { rootComponents } = globalThis.LWR;
@@ -106,6 +114,14 @@ Promise.all(rootComponents.map(async (rootSpecifier) => {
106
114
  const viewMetadata = globalThis._lwrRuntimeDebug.viewMetadata;
107
115
  const hmrEndpoint = globalThis.LWR.endpoints.uris.hmr;
108
116
  initHMR(hmrEndpoint, viewMetadata);`,
117
+ // LAST TASK: Cleanup globalThis.LWR in ESM (the shim does this for AMD)
118
+ isESM && `delete globalThis.LWR;`,
119
+ // LAST TASK: Cleanup globalThis.LWR in AMD
120
+ isAMD &&
121
+ `
122
+ globalThis.LWR = Object.freeze({
123
+ define: globalThis.LWR.define,
124
+ });`,
109
125
  ]
110
126
  .filter(Boolean)
111
127
  .join('\n');
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.5.11-alpha.1",
8
- "homepage": "https://lwr.dev/",
7
+ "version": "0.6.0-alpha.10",
8
+ "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/salesforce/lwr.git",
@@ -33,14 +33,14 @@
33
33
  "build/**/*.d.ts"
34
34
  ],
35
35
  "dependencies": {
36
- "@lwrjs/diagnostics": "0.5.11-alpha.1",
37
- "@lwrjs/shared-utils": "0.5.11-alpha.1"
36
+ "@lwrjs/diagnostics": "0.6.0-alpha.10",
37
+ "@lwrjs/shared-utils": "0.6.0-alpha.10"
38
38
  },
39
39
  "devDependencies": {
40
- "@lwrjs/types": "0.5.11-alpha.1"
40
+ "@lwrjs/types": "0.6.0-alpha.10"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=14.15.4 <17"
44
44
  },
45
- "gitHead": "6ffcda9842a44918f0e2b2aefea84c30d3e4ef55"
45
+ "gitHead": "85914e17d6214748489426252dd8fa41c8938b8f"
46
46
  }