-
Notifications
You must be signed in to change notification settings - Fork 27.2k
ngcc: implement ivy switch rendering #25534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a5173e8
3b7df99
4a51bb1
9a0c285
a5f679f
29457cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,24 @@ const CLASSES = [ | |
| }, | ||
| ]; | ||
|
|
||
| const MARKER_FILE = { | ||
| name: '/marker.js', | ||
| contents: ` | ||
| let compileNgModuleFactory = compileNgModuleFactory__PRE_NGCC__; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't mind a test with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh. 👍
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
|
||
| function compileNgModuleFactory__PRE_NGCC__(injector, options, moduleType) { | ||
| const compilerFactory = injector.get(CompilerFactory); | ||
| const compiler = compilerFactory.createCompiler([options]); | ||
| return compiler.compileModuleAsync(moduleType); | ||
| } | ||
|
|
||
| function compileNgModuleFactory__POST_NGCC__(injector, options, moduleType) { | ||
| ngDevMode && assertNgModuleType(moduleType); | ||
| return Promise.resolve(new R3NgModuleFactory(moduleType)); | ||
| } | ||
| ` | ||
| }; | ||
|
|
||
| describe('Esm2015ReflectionHost', () => { | ||
| describe('getGenericArityOfClass()', () => { | ||
| it('should properly count type parameters', () => { | ||
|
|
@@ -52,4 +70,18 @@ describe('Esm2015ReflectionHost', () => { | |
| expect(host.getGenericArityOfClass(twoTypeParamsClass)).toBe(2); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getSwitchableDeclarations()', () => { | ||
| it('should return a collection of all the switchable variable declarations in the given module', | ||
| () => { | ||
| const program = makeProgram(MARKER_FILE); | ||
| const dtsMapper = new DtsMapper('/src', '/typings'); | ||
| const host = new Esm2015ReflectionHost(program.getTypeChecker(), dtsMapper); | ||
| const file = program.getSourceFile(MARKER_FILE.name) !; | ||
| const declarations = host.getSwitchableDeclarations(file); | ||
| expect(declarations.map(d => [d.name.getText(), d.initializer !.getText()])).toEqual([ | ||
| ['compileNgModuleFactory', 'compileNgModuleFactory__PRE_NGCC__'] | ||
| ]); | ||
| }); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make this a method on the
ReflectionHost. Having both standalone functions and Class methods gets confusing (imo).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have lots of type constraint functions in the ngcc and ngtsc code. They are all standalone.