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
Angular linker cannot compile umd.min.js #41655
Comments
Can you please share the relevant partial declaration code? By the way, minfied UMD bundles are being removed in APF v12 and will no longer be generated by ng-packagr. |
Since I can't share the code of the library that failed, I will try to create some reproduction library. I also have some custom webpack minified UMD build that passes Linker but no View instructions are created as output for some reason. Since this UMD also contains other libraries bundled maybe it is because of that. Regarding APF v12 this is fine, but still it is good to have option to obfuscate code with webpack or something else for non public sources |
I cannot create a reproduction library since just adding: import { Component } from '@angular/core';
@Component({
selector: 'lib-sample-component',
template: `
<p>
authentication-module works!
</p>
`,
styles: []
})
export class SampleUiComponent {
constructor() { }
} this component make UMD.min.js file to fail. On the other hand I don't think that it has something to do with the component itself since when I add same component to some other library project it passes. I also have another component for test which is more complex and when I remove some inheritance from component it starts working but I don't see a clear reason why it fails sometimes. UPDATE: It works regulary if I do unminify with Babel before aplying plugin UPDATE 2 Reason why webpack compiled UMD is not working is because it uses Index notation instead of dot notation and this is somehow ignored by linker: o["傻傻ngDeclareComponent"] is not processed but o.傻傻ngDeclareComponent is processed |
I managed to get a simular error with reference to code:
!0 is the part that makes an issue |
Ah, that's what I was expecting! We should be able to support that, but I'm wondering if there's more things that can happen. |
This is what I get from regular Angular lib. It optimizes false to !1 and true to !0. And because of that link fails. I can confirm that changing this with regex before makes linker working. WORKAROUND: const regex = /o\["傻傻(.*?)"]/gm;
file.source = file.source.replace(regex, function (a, b) {
return 'o.傻傻' + b;
})
file.source = file.source.replace(/\!0/gm, 'true');
file.source = file.source.replace(/\!1/gm, 'false'); In general I tested few libraries with build such as angular-l10n and ng-bootstrap but didn't have the issue with boolean properties. I am not sure if there is some tsconfig or other parameter to dismiss such optimization |
Some partial libraries have been minified, which results in boolean literals being converted to `!0` and `!1`. This commit ensures that the linker can process these values. Fixes angular#41655
Some partial libraries have been minified, which results in the declaration calls being being converted from property accesses to indexed accesses. This commit ensures that the linker can process these calls. Fixes angular#41655
Some partial libraries have been minified, which results in boolean literals being converted to `!0` and `!1`. This commit ensures that the linker can process these values. Fixes angular#41655
Some partial libraries have been minified, which results in the declaration calls being being converted from property accesses to indexed accesses. This commit ensures that the linker can process these calls. Fixes angular#41655
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
@angular/compiler 11.2.10 and 12.0.0-next9
Description
When I try to compile umd.min.js file (from partial build of Library) with Angular linker (Babel plugin) I get following error:
umd.js file compiles without any problem
馃敩 Minimal Reproduction
For compilation I used following script:
馃敟 Exception or Error
馃實 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: