@lwrjs/app-service
Advanced tools
Comparing version 0.0.2-alpha18 to 0.0.2-alpha19
@@ -56,3 +56,3 @@ "use strict"; | ||
const rootModules = metadata.customElements.map(shared_utils_1.kebabcaseToCamelcase); | ||
if (!rootModules.includes(this.appContext.root)) { | ||
if (requestPath === '/' && !rootModules.includes(this.appContext.root)) { | ||
// If the root application module is not included in the root module array, add it | ||
@@ -59,0 +59,0 @@ // This happens when the 'lwr-root' HTML property is used for root insertion (see init.ts) |
@@ -33,2 +33,3 @@ "use strict"; | ||
const servicesSource = isAMD && loaderServices && createLoaderServicesSource(loaderServices); | ||
const versionedRootCmps = isAMD && (await Promise.all(rootComponents.map((s) => shared_utils_1.getVersionedSpecifier(s, moduleRegistry)))); | ||
const importRootModules = rootComponents.map((wc, index) => `import Ctor${index} from '${wc}'`); | ||
@@ -39,8 +40,9 @@ return [ | ||
syntheticShadow && `import '@lwc/synthetic-shadow';`, | ||
//services | ||
// loader services/hooks (AMD format only) | ||
isAMD && | ||
`import { load ${loaderServices && loaderServices.length ? ', services' : ''}} from 'lwr/loader';`, | ||
// import dependencies | ||
servicesSource, | ||
// import dependencies statically (ESM format only) | ||
isESM && importRootModules.join('\n'), | ||
// hmr | ||
// HMR (ESM format only)mr | ||
isESM && `import { initHMR } from 'lwr/hmr';`, | ||
@@ -50,9 +52,9 @@ isESM && `import { initESM } from 'lwr/moduleInvalidationInitESM';`, | ||
`import { init } from '${initModule}';`, | ||
// serviceSources | ||
servicesSource, | ||
// initialize | ||
// initialize root components | ||
isESM | ||
? `init([${rootComponents.map((r, i) => `["${r}", Ctor${i}]`)}]); initHMR(); initESM();` | ||
: // TODO: This only initializes the first of the root components | ||
`const rootCmp = globalThis.LWR.rootComponent || '${await shared_utils_1.getVersionedSpecifier(rootComponents[0], moduleRegistry)}';\nload(rootCmp).then(({ default: Ctor }) => { init([[rootCmp, Ctor]]); });`, | ||
: `const rootCmps = ${JSON.stringify(versionedRootCmps)}; | ||
const appRoot = globalThis.LWR.rootComponent; | ||
appRoot && !rootCmps.includes(appRoot) && rootCmps.push(appRoot); | ||
rootCmps.forEach(c => load(c).then(({ default: Ctor }) => { init([[c, Ctor]]); }));`, | ||
] | ||
@@ -59,0 +61,0 @@ .filter(Boolean) |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.2-alpha18", | ||
"version": "0.0.2-alpha19", | ||
"homepage": "https://lwr.dev/", | ||
@@ -27,5 +27,5 @@ "repository": { | ||
"dependencies": { | ||
"@lwrjs/shared-utils": "0.0.2-alpha18" | ||
"@lwrjs/shared-utils": "0.0.2-alpha19" | ||
}, | ||
"gitHead": "9cf922f2e624d3255ab89d39a019be4e88793c61" | ||
"gitHead": "96059521952c09f1a411f0aea3fed204a9bd5303" | ||
} |
20698
398
+ Added@lwrjs/shared-utils@0.0.2-alpha19(transitive)
- Removed@lwrjs/shared-utils@0.0.2-alpha18(transitive)