@lwrjs/app-service
Advanced tools
Comparing version 0.0.2-alpha24 to 0.0.2-alpha25
@@ -12,3 +12,3 @@ import { PublicModuleRegistry, NormalizedLwrApplicationConfig } from '@lwrjs/types'; | ||
*/ | ||
export declare function createVirtualSource(rootComponents: string[], { init: initModule, loaderServices, syntheticShadow }: NormalizedLwrApplicationConfig, format: string, moduleRegistry: PublicModuleRegistry): Promise<string>; | ||
export declare function createVirtualSource(rootComponents: string[], { init: initModule, services, syntheticShadow }: NormalizedLwrApplicationConfig, format: string, moduleRegistry: PublicModuleRegistry): Promise<string>; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
} | ||
function createLoaderServicesSource(services) { | ||
function createServicesSource(services) { | ||
const imports = services.map((service) => { | ||
@@ -30,6 +30,6 @@ const defaultImportName = getDefaultImportName(service); | ||
*/ | ||
async function createVirtualSource(rootComponents, { init: initModule, loaderServices, syntheticShadow }, format, moduleRegistry) { | ||
async function createVirtualSource(rootComponents, { init: initModule, services, syntheticShadow }, format, moduleRegistry) { | ||
const isAMD = format === 'amd'; | ||
const isESM = format === 'esm'; | ||
const servicesSource = isAMD && loaderServices && createLoaderServicesSource(loaderServices); | ||
const servicesSource = services && createServicesSource(services); | ||
const versionedRootCmps = isAMD && (await Promise.all(rootComponents.map((s) => shared_utils_1.getVersionedSpecifier(s, moduleRegistry)))); | ||
@@ -41,5 +41,7 @@ const importRootModules = rootComponents.map((wc, index) => `import Ctor${index} from '${wc}'`); | ||
syntheticShadow && `import '@lwc/synthetic-shadow';`, | ||
// loader services/hooks (AMD format only) | ||
isAMD && | ||
`import { load ${loaderServices && loaderServices.length ? ', services' : ''}} from 'lwr/loader';`, | ||
// import the loader and services for AMD | ||
isAMD && `import { load ${services && services.length ? ', services' : ''}} from 'lwr/loader';`, | ||
// import ESM version of ServiceAPI | ||
!isAMD && services && services.length && `import { services } from 'lwr/servicesESM';`, | ||
// import and register the configured services | ||
servicesSource, | ||
@@ -50,3 +52,2 @@ // import dependencies statically (ESM format only) | ||
isESM && `import { initHMR } from 'lwr/hmr';`, | ||
isESM && `import { initESM } from 'lwr/moduleInvalidationInitESM';`, | ||
// init module | ||
@@ -56,3 +57,3 @@ `import { init } from '${initModule}';`, | ||
isESM | ||
? `init([${rootComponents.map((r, i) => `["${r}", Ctor${i}]`)}]); initHMR(); initESM();` | ||
? `init([${rootComponents.map((r, i) => `["${r}", Ctor${i}]`)}]); initHMR();` | ||
: `const rootCmps = ${JSON.stringify(versionedRootCmps)}; | ||
@@ -59,0 +60,0 @@ const appRoot = globalThis.LWR.rootComponent; |
@@ -24,3 +24,3 @@ "use strict"; | ||
const { mode, format } = context; | ||
const { name: configuredAppName, root: appRoot, workers, loaderServices, autoBoot = true, } = this.appContext; | ||
const { name: configuredAppName, root: appRoot, workers, services, autoBoot = true, } = this.appContext; | ||
const { type, appName } = shared_utils_1.parseSyntheticSpecifier(specifier); | ||
@@ -39,3 +39,3 @@ // Reject the request if the app name (from config) or version (from package.json) do not match | ||
if (type === shared_utils_1.CONFIG_NAMESPACE) { | ||
return await utils_1.createBootstrapConfig({ specifier, mode, format, loaderServices, autoBoot }, context, this.moduleRegistry); | ||
return await utils_1.createBootstrapConfig({ specifier, mode, format, services, autoBoot }, context, this.moduleRegistry); | ||
} | ||
@@ -42,0 +42,0 @@ } |
@@ -7,3 +7,3 @@ import { BootstrapRuntimeContext, PublicModuleRegistry, PublicResourceRegistry, ResourceDefinition, RuntimeContext } from '@lwrjs/types'; | ||
autoBoot: boolean; | ||
loaderServices: string[]; | ||
services: string[]; | ||
} | ||
@@ -10,0 +10,0 @@ /** |
@@ -21,3 +21,3 @@ "use strict"; | ||
async function createBootstrapConfig(context, runtimeContext, moduleRegistry) { | ||
const { specifier, mode, format, autoBoot, loaderServices } = context; | ||
const { specifier, mode, format, autoBoot, services } = context; | ||
let loaderConfigStr = ''; | ||
@@ -29,3 +29,3 @@ if (format === 'amd') { | ||
let requiredModules = []; | ||
if (loaderServices.length) { | ||
if (services.length) { | ||
requiredModules = | ||
@@ -32,0 +32,0 @@ runtimeContext.bootstrapImports || |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.2-alpha24", | ||
"version": "0.0.2-alpha25", | ||
"homepage": "https://lwr.dev/", | ||
@@ -27,5 +27,5 @@ "repository": { | ||
"dependencies": { | ||
"@lwrjs/shared-utils": "0.0.2-alpha24" | ||
"@lwrjs/shared-utils": "0.0.2-alpha25" | ||
}, | ||
"gitHead": "4fbb550ce5f6b71419c68a4fa61156a0d15caa9a" | ||
"gitHead": "18d972e33dacc445f6e0495edcf808fe61b3984a" | ||
} |
20684
398
+ Added@lwrjs/shared-utils@0.0.2-alpha25(transitive)
- Removed@lwrjs/shared-utils@0.0.2-alpha24(transitive)