fix(core): ensure that `ɵdefineNgModule` is available in flat-file formats (#26403)

When compiling the flat-file version of the `@angular/core` we need to be aware
that we cannot rely upon imported names to access the ivy definition functions.
The compiler is already clever enough to use local function calls rather than
trying to add a namespaced import, but there is a problem if the local name of the
function is different to the exported name. This is the case for functions that
are not part of the public API, and so are exported under a barred-O private alias.

In `@angular/core` the only decorations in use are `@NgModule` and `@Injectable`.
There are no directives, components, pipes, etc.

Since `defineInjectable` is part of the public API of `@angular/core`, the compiler
is able to generate code that references the original non-barred-O version of the
function.

But the `defineNgModule` is not part of the public API and so the compiler must
generate code that refers to it by the private barred-O version of the function.

This commit imports and then re-exports this barred-O version of `defineModule` to
ensure that the symbol is available in the local scope of the flat-file versions of
the `@angular/core` library.

PR Close #26403
This commit is contained in:
Pete Bacon Darwin 2018-10-04 21:15:31 +01:00 committed by Kara Erickson
parent 2f30bbb495
commit a64859b4bc
3 changed files with 10 additions and 1 deletions

View File

@ -7,12 +7,15 @@
*/
// clang-format off
// We need to have `ɵdefineNgModule` defined locally for flat-file ngcc compilation.
// More details in the commit where this is added.
import {defineNgModule} from './render3/index';
export const ɵdefineNgModule = defineNgModule;
export {
defineBase as ɵdefineBase,
defineComponent as ɵdefineComponent,
defineDirective as ɵdefineDirective,
definePipe as ɵdefinePipe,
defineNgModule as ɵdefineNgModule,
detectChanges as ɵdetectChanges,
renderComponent as ɵrenderComponent,
ComponentType as ɵComponentType,

View File

@ -4633,5 +4633,8 @@
},
{
"name": "ɵResourceLoaderImpl_BaseFactory"
},
{
"name": "ɵdefineNgModule"
}
]

View File

@ -2671,5 +2671,8 @@
},
{
"name": "wtfLeave"
},
{
"name": "ɵdefineNgModule"
}
]