@lwrjs/app-service
Advanced tools
Comparing version 0.0.2-alpha8 to 0.0.2-alpha9
@@ -1,2 +0,2 @@ | ||
import { CompiledModule, LwrApplicationConfig, ModuleEntry, ModuleIdentifier, ModuleProvider, ModuleSource, ProviderContext, ResolverConfig, RuntimeContext, RendererRegistry } from '@lwrjs/types'; | ||
import { CompiledModule, LwrApplicationConfig, ModuleEntry, ModuleIdentifier, ModuleProvider, ModuleSource, ProviderContext, ResolverConfig, RuntimeContext, ViewRegistry } from '@lwrjs/types'; | ||
export default class AppService implements ModuleProvider { | ||
@@ -6,3 +6,3 @@ name: string; | ||
appContext: LwrApplicationConfig; | ||
rendererRegistry: RendererRegistry; | ||
rendererRegistry: ViewRegistry; | ||
private compiler; | ||
@@ -9,0 +9,0 @@ constructor({ compiler, rendererRegistry, config: { application } }: ProviderContext); |
@@ -24,3 +24,3 @@ "use strict"; | ||
const { mode, format } = context; | ||
const { name: appName, root: appRoot, workers, autoBoot = true } = this.appContext; | ||
const { name: appName, root: appRoot, workers, loaderServices, autoBoot = true } = this.appContext; | ||
// Check if the resource is JSON for an app | ||
@@ -36,3 +36,3 @@ // expected format: @webruntime/json/my/app | ||
if (specifier.startsWith(utils_1.CONFIG_PACKAGE) && configSpecifier === appName && version === this.version) { | ||
return await utils_1.createBootstrapConfig({ appName, appRoot, mode, format, autoBoot }, this.moduleRegistry); | ||
return await utils_1.createBootstrapConfig({ appName, appRoot, mode, format, loaderServices, autoBoot, version: this.version }, context, this.moduleRegistry); | ||
} | ||
@@ -39,0 +39,0 @@ } |
@@ -8,3 +8,5 @@ import { PublicModuleRegistry, PublicResourceRegistry, ResourceDefinition, RuntimeContext } from '@lwrjs/types'; | ||
format: string; | ||
version: string; | ||
autoBoot: boolean; | ||
loaderServices: string[]; | ||
} | ||
@@ -17,3 +19,3 @@ /** | ||
*/ | ||
export declare function createBootstrapConfig({ appName, appRoot, mode, format, autoBoot }: ConfigContext, moduleRegistry: PublicModuleRegistry): Promise<ResourceDefinition>; | ||
export declare function createBootstrapConfig(context: ConfigContext, runtimeContext: RuntimeContext, moduleRegistry: PublicModuleRegistry): Promise<ResourceDefinition>; | ||
export declare const JSON_PACKAGE = "@webruntime/json/"; | ||
@@ -20,0 +22,0 @@ interface JsonContext { |
@@ -12,2 +12,18 @@ "use strict"; | ||
exports.CONFIG_PACKAGE = '@webruntime/config/'; | ||
async function getBootstrapModuleDependencies({ appRoot, loaderServices, version }, runtimeContext, moduleRegistry) { | ||
let specifiers = []; | ||
if (loaderServices.length) { | ||
const bootstrapModuleDef = await moduleRegistry.getModule({ | ||
namespace: appRoot, | ||
name: 'bootstrap', | ||
version, | ||
resourceType: 'bootstrap', | ||
}, runtimeContext); | ||
if (bootstrapModuleDef) { | ||
const bootstrapDeps = bootstrapModuleDef.moduleDefinition.moduleRecord.imports || []; | ||
specifiers = await Promise.all(bootstrapDeps.map(({ specifier }) => specifier)); | ||
} | ||
} | ||
return specifiers; | ||
} | ||
/** | ||
@@ -19,3 +35,4 @@ * Create the Client Bootstrap Config JSON | ||
*/ | ||
async function createBootstrapConfig({ appName, appRoot, mode, format, autoBoot }, moduleRegistry) { | ||
async function createBootstrapConfig(context, runtimeContext, moduleRegistry) { | ||
const { appName, appRoot, mode, format, autoBoot } = context; | ||
let loaderConfigStr = ''; | ||
@@ -28,2 +45,4 @@ if (format === 'amd') { | ||
]); | ||
// If loader services/hooks are used, add all ABS module dependencies to requiredModules[] | ||
const requiredModules = await getBootstrapModuleDependencies(context, runtimeContext, moduleRegistry); | ||
// Add AMD Loader Shim properties | ||
@@ -38,3 +57,3 @@ const config = { | ||
// because order is not guaranteed with async | ||
requiredModules: [bootstrapModuleSpecifier], | ||
requiredModules: [bootstrapModuleSpecifier, ...requiredModules], | ||
}; | ||
@@ -41,0 +60,0 @@ loaderConfigStr += `\nglobalThis.LWR = globalThis.LWR || {};\nObject.assign(globalThis.LWR, ${JSON.stringify(config)});`; |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.2-alpha8", | ||
"version": "0.0.2-alpha9", | ||
"homepage": "https://lwr.dev/", | ||
@@ -27,5 +27,5 @@ "repository": { | ||
"dependencies": { | ||
"@lwrjs/shared-utils": "0.0.2-alpha8" | ||
"@lwrjs/shared-utils": "0.0.2-alpha9" | ||
}, | ||
"gitHead": "c010a3b75892789968c39442644bf333a59529c9" | ||
"gitHead": "082cdd98d88f586287d1bc5e20fee3ad024708f1" | ||
} |
19984
397
+ Added@lwrjs/shared-utils@0.0.2-alpha9(transitive)
- Removed@lwrjs/shared-utils@0.0.2-alpha8(transitive)