build: add moduleName to ngFactory sourcefiles (#29385)
PR Close #29385
This commit is contained in:

committed by
Matias Niemelä

parent
ae4a86e3b5
commit
86aba1e8f3
@ -213,6 +213,40 @@ describe('NgCompilerHost', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('addGeneratedFile', () => {
|
||||
function generate(path: string, files: {}) {
|
||||
codeGenerator.findGeneratedFileNames.and.returnValue([`${path}.ngfactory.ts`]);
|
||||
codeGenerator.generateFile.and.returnValue(
|
||||
new compiler.GeneratedFile(`${path}.ts`, `${path}.ngfactory.ts`, []));
|
||||
const host = createHost({
|
||||
files,
|
||||
options: {
|
||||
basePath: '/tmp',
|
||||
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
||||
// Request UMD, which should get default module names
|
||||
module: ts.ModuleKind.UMD
|
||||
},
|
||||
});
|
||||
return host.getSourceFile(`${path}.ngfactory.ts`, ts.ScriptTarget.Latest);
|
||||
}
|
||||
|
||||
it('should include a moduleName when the file is in node_modules', () => {
|
||||
const genSf = generate(
|
||||
'/tmp/node_modules/@angular/core/core',
|
||||
{'tmp': {'node_modules': {'@angular': {'core': {'core.ts': `// some content`}}}}});
|
||||
expect(genSf.moduleName).toBe('@angular/core/core.ngfactory');
|
||||
});
|
||||
|
||||
it('should not get tripped on nested node_modules', () => {
|
||||
const genSf = generate('/tmp/node_modules/lib1/node_modules/lib2/thing', {
|
||||
'tmp': {
|
||||
'node_modules': {'lib1': {'node_modules': {'lib2': {'thing.ts': `// some content`}}}}
|
||||
}
|
||||
});
|
||||
expect(genSf.moduleName).toBe('lib2/thing.ngfactory');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSourceFile', () => {
|
||||
it('should cache source files by name', () => {
|
||||
const host = createHost({files: {'tmp': {'src': {'index.ts': ``}}}});
|
||||
|
Reference in New Issue
Block a user