mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(core): remove module bootstrap code when using standalone. (#59208)
This commit improves tree shaking in standalone apps. PR Close #59208
This commit is contained in:
parent
33a336f74a
commit
c2c8b75d7b
6 changed files with 28 additions and 3 deletions
|
|
@ -162,7 +162,7 @@ export function bootstrap<M>(
|
|||
}
|
||||
return appRef;
|
||||
} else {
|
||||
moduleDoBootstrap(config.moduleRef, config.allPlatformModules);
|
||||
moduleBootstrapImpl?.(config.moduleRef, config.allPlatformModules);
|
||||
return config.moduleRef;
|
||||
}
|
||||
});
|
||||
|
|
@ -170,7 +170,20 @@ export function bootstrap<M>(
|
|||
});
|
||||
}
|
||||
|
||||
function moduleDoBootstrap(
|
||||
/**
|
||||
* Having a separate symbol for the module boostrap implementation allows us to
|
||||
* tree shake the module based boostrap implementation in standalone apps.
|
||||
*/
|
||||
let moduleBootstrapImpl: undefined | typeof _moduleDoBootstrap;
|
||||
|
||||
/**
|
||||
* Set the implementation of the module based bootstrap.
|
||||
*/
|
||||
export function setModuleBootstrapImpl() {
|
||||
moduleBootstrapImpl = _moduleDoBootstrap;
|
||||
}
|
||||
|
||||
function _moduleDoBootstrap(
|
||||
moduleRef: InternalNgModuleRef<any>,
|
||||
allPlatformModules: NgModuleRef<unknown>[],
|
||||
): void {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import {CompilerOptions} from '../linker';
|
|||
import {NgModuleFactory, NgModuleRef} from '../linker/ng_module_factory';
|
||||
import {createNgModuleRefWithProviders} from '../render3/ng_module_ref';
|
||||
import {getNgZone} from '../zone/ng_zone';
|
||||
import {bootstrap} from './bootstrap';
|
||||
import {bootstrap, setModuleBootstrapImpl} from './bootstrap';
|
||||
import {PLATFORM_DESTROY_LISTENERS} from './platform_destroy_listeners';
|
||||
|
||||
/**
|
||||
|
|
@ -77,6 +77,7 @@ export class PlatformRef {
|
|||
allAppProviders,
|
||||
);
|
||||
|
||||
setModuleBootstrapImpl();
|
||||
return bootstrap({
|
||||
moduleRef,
|
||||
allPlatformModules: this._modules,
|
||||
|
|
@ -107,6 +108,7 @@ export class PlatformRef {
|
|||
| Array<CompilerOptions & BootstrapOptions> = [],
|
||||
): Promise<NgModuleRef<M>> {
|
||||
const options = optionsReducer({}, compilerOptions);
|
||||
setModuleBootstrapImpl();
|
||||
return compileNgModuleFactory(this.injector, options, moduleType).then((moduleFactory) =>
|
||||
this.bootstrapModuleFactory(moduleFactory, options),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@
|
|||
"_isRefreshingViews",
|
||||
"_keyMap",
|
||||
"_locateOrCreateElementNode",
|
||||
"_moduleDoBootstrap",
|
||||
"_platformInjector",
|
||||
"_testabilityGetter",
|
||||
"_wasLastNodeCreated",
|
||||
|
|
@ -345,6 +346,7 @@
|
|||
"maybeWrapInNotSelector",
|
||||
"mergeHostAttribute",
|
||||
"mergeHostAttrs",
|
||||
"moduleBootstrapImpl",
|
||||
"nativeAppendChild",
|
||||
"nativeAppendOrInsertBefore",
|
||||
"nativeInsertBefore",
|
||||
|
|
@ -399,6 +401,7 @@
|
|||
"setInjectImplementation",
|
||||
"setInputsFromAttrs",
|
||||
"setIsRefreshingViews",
|
||||
"setModuleBootstrapImpl",
|
||||
"setSelectedIndex",
|
||||
"setShadowStylingInputFlags",
|
||||
"setupHostDirectiveInputsOrOutputs",
|
||||
|
|
|
|||
|
|
@ -413,6 +413,7 @@
|
|||
"maybeWrapInNotSelector",
|
||||
"mergeHostAttribute",
|
||||
"mergeHostAttrs",
|
||||
"moduleBootstrapImpl",
|
||||
"nativeAppendChild",
|
||||
"nativeAppendOrInsertBefore",
|
||||
"nativeInsertBefore",
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@
|
|||
"_locateOrCreateContainerAnchor",
|
||||
"_locateOrCreateElementNode",
|
||||
"_locateOrCreateTextNode",
|
||||
"_moduleDoBootstrap",
|
||||
"_platformInjector",
|
||||
"_testabilityGetter",
|
||||
"_wasLastNodeCreated",
|
||||
|
|
@ -514,6 +515,7 @@
|
|||
"mergeHostAttrs",
|
||||
"mergeInputsWithTransforms",
|
||||
"mergeValidators",
|
||||
"moduleBootstrapImpl",
|
||||
"multiFactoryAdd",
|
||||
"multiProvidersFactoryResolver",
|
||||
"multiResolve",
|
||||
|
|
@ -594,6 +596,7 @@
|
|||
"setInjectImplementation",
|
||||
"setInputsFromAttrs",
|
||||
"setIsRefreshingViews",
|
||||
"setModuleBootstrapImpl",
|
||||
"setSelectedIndex",
|
||||
"setShadowStylingInputFlags",
|
||||
"setTStylingRangeNext",
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@
|
|||
"_locateOrCreateContainerAnchor",
|
||||
"_locateOrCreateElementNode",
|
||||
"_locateOrCreateTextNode",
|
||||
"_moduleDoBootstrap",
|
||||
"_platformInjector",
|
||||
"_testabilityGetter",
|
||||
"_wasLastNodeCreated",
|
||||
|
|
@ -503,6 +504,7 @@
|
|||
"mergeInputsWithTransforms",
|
||||
"mergeValidators",
|
||||
"modelGroupProvider",
|
||||
"moduleBootstrapImpl",
|
||||
"multiFactoryAdd",
|
||||
"multiProvidersFactoryResolver",
|
||||
"multiResolve",
|
||||
|
|
@ -588,6 +590,7 @@
|
|||
"setInjectImplementation",
|
||||
"setInputsFromAttrs",
|
||||
"setIsRefreshingViews",
|
||||
"setModuleBootstrapImpl",
|
||||
"setPropertyAndInputs",
|
||||
"setSelectedIndex",
|
||||
"setShadowStylingInputFlags",
|
||||
|
|
|
|||
Loading…
Reference in a new issue