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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngcc: doesn't process library prefixed exports properly #38238
Comments
I can reproduce locally in a small setup. Compiling the libraries directly for Ivy does not show the issue for me, so it does indeed appear to be specific to ngcc. |
@JoostK I've tried to compile them with different tsconfig options with no joy. Our way to go at the moment will be to keep the Libraries in Angular 8 |
A little update: angular/packages/compiler-cli/ngcc/src/host/esm2015_host.ts Lines 1605 to 1611 in 8fbf40b
I am still not sure what is the best way to fix it. Annoyingly, I haven't been able to correctly reproduce this in a unit test in esm2015_host_spec.ts yet 馃槩 Example failing test// ...
describe('getConstructorParameters()', () => {
// ...
it('should find the decorated constructor parameters', () => {
const files = [
{
name: _('/node_modules/shared-lib/package.json'),
contents: `
{
"name": "shared-lib",
"es2015": "./index.js",
"types": "./index.d.ts"
}
`,
},
{
name: _('/node_modules/shared-lib/foo.d.ts'),
contents: `
declare class Foo {
}
export Foo as Bar;
`,
},
{
name: _('/node_modules/shared-lib/foo.js'),
contents: `
class Foo {
}
export Foo as Bar;
`,
},
{
name: _('/node_modules/shared-lib/index.d.ts'),
contents: `
export {Bar as Baz} from './foo';
`,
},
{
name: _('/node_modules/shared-lib/index.js'),
contents: `
export {Bar as Baz} from './foo';
`,
},
{
name: _('/main.d.ts'),
contents: `
import {Baz} from 'shared-lib/index';
export declare class SomeClass {
constructor(arg1: Baz) {
}
}
`,
},
{
name: _('/main.js'),
contents: `
import {Baz} from 'shared-lib/index';
export class SomeClass {
constructor(arg1) {
}
}
SomeClass.ctorParameters = [{ type: Baz }];
`,
},
];
loadFakeCore(getFileSystem());
loadTestFiles(files);
const bundle = makeTestBundleProgram(_('/main.js'));
const host = createHost(bundle, new Esm2015ReflectionHost(new MockLogger(), false, bundle));
const classNode = getDeclaration(
bundle.program, _('/main.js'), 'SomeClass', isNamedClassDeclaration);
const parameters = host.getConstructorParameters(classNode)!;
expect(parameters).toEqual([jasmine.objectContaining({name: 'arg1'})]);
expectTypeValueReferencesForParameters(parameters, ['Qux'], 'shared-lib');
});
}); I would expect that the |
wow, amazing tracking of the issue tho. |
@gkalpak your failing test was almost perfect. There was just a minor typo in the export aliases: class Foo {}
export Foo as Bar; should be class Foo {}
export {Foo as Bar}; Now (for me) it is failing (as expected) with
and
(although I think we actually mean |
馃檱 Good timing too - I was planning to get back to it today or tomorrow. |
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
Duplicate of # |
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
If a type has been renamed when it was exported, we need to reference the external public alias name rather than the internal original name for the type. Otherwise we will try to import the type by its internal name, which is not publicly accessible. Fixes angular#38238
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
馃悶 bug report
Affected Package
The issue is caused by package
@angular/compiler-cli
, package wherengcc
belongs.Is this a regression?
No, this is the first time we're trying to upgrade from Angular 8 to 9.
Description
We have 30+ Angular Libraries released with Angular v8 right now.
Upgrading the websites from v8 to v9,
ngcc
throws exceptions from the compiled files of our libraries (__ivy_ngcc__/fesm2015/app.js
). The exceptions are related to Injectables consumed from our/common
library.The issue is that we export our Services with the company prefix,
and
ngcc
is not compiling the libraries properly missing such prefix and not finding the Service.I will go deep in the exception to illustrate the problem.
馃敟 Exception or Error
Where
node_modules/@company/services/__ivy_ngcc__/fesm2015/app.js
has:but
傻ngcc1.HttpService
does not exists, it should bePrefixHttpService
.Looking at
node_modules/@company/services/fesm2015/app.js
it seems ok:Then Ivy's compiler is removing the Prefix for some reason :(
the library's
index.d.ts
correctly maps them as:馃敩 Minimal Reproduction
I will provide enough details to show the problem, as a reproduction is complicated right now.
I can mount a reproduction the next weekend if it's required.
馃實 Your Environment
Angular Version:
Anything else relevant?
@gkalpak I've seen some PRs from you fixing re-exports, and this topic seems related to your work.
Could you give us a hand here please? thanks in advance!!
The text was updated successfully, but these errors were encountered: