Generated code for built library is faulty
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
Building a library with Ivy either disabled or enabled results in wrong generated code.
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e; // <----- set default property
return Object.freeze(n);
}
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
// namespace called without default property
ModuleaService.ɵprov = i0__namespace.ɵɵdefineInjectable(...);
How To Reproduce
Minimal reproduction is available here projects/ngpluginsrepro is an app that loads the generated modules from the projects/plugins workspace. Generated modules are included into the app’s assets. You will find 2 working examples in the app’s assets, modulea.umd.js and moduleb.umd.js. However, I cannot build the modules anymore. (Reverting to this commit and reinstalling node_modules doesn’t help).
Expected Behaviour
I cannot explain the inconsistency, but I used to be able to build the libraries. The ngpluginsrepro app would then load these modules at runtime and compile them as Angular modules (also includes lazy-loading and routing to these modules).
Version Information
ng-packagr: 10.1.2
@angular/*: 10.1.6
typescript: 4.0.7
rxjs: 6.6.7
node: 12.18.3
npm/yarn: 6.14.6 / 1.22.10
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
xdc.cfg.SourceDir : Build of generated source libraries failed ...
Tool/software: Code Composer Studio When building a TI-RTOS based CCS project it fails with the following error: error: xdc.cfg.
Read more >Problem with static library in C++ - visual studio - Stack Overflow
I declare one function "int myF(int a);" into a .h file, I implement it in a .cpp file, I compile it - the...
Read more >Why is the c/c++ code generated by MATLAB Coder not ...
So I think that the generated c/c++ code depends on additional library. Finally, I add all the header files, library files and dll...
Read more >CubeMX 6.0.0 bug report: library creation and copying have ...
The Code is sccessfully generated under {my path} , but Library creation and copy have a problem. QQ截图20200801191233. . At first I thought ......
Read more >Building Projects — Emscripten 3.1.26-git (dev) documentation
Built -in support is available for a number of standard libraries: libc, libc++ and SDL. These will automatically be linked when you compile...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
UMD bundles generated from the projects/plugins workspace (and inserted as assets into the projects/ngpluginsrepro app) are no longer loaded by systemjs.
Using
systemjs: 0.21.6
I suspected it was a problem with ng-packagr (initial description) but to be perfectly honest I’m not sure… Any pointers are greatly appreciated.
Thank you @ratatoeskr666 for making me get back into this.
After some more testing, some clarification is needed.
Using Angular 9, UMD modules are built and loaded by SystemJS without any issues (whether Ivy is enabled or not when building). Whereas using Angular 10 and up, there are different results.
Disabling Ivy and using the interopNamespace leads to
Cannot read property 'ɵɵdefineInjectable' of undefined
above.Enabling Ivy and using the interopNamespace also leads to
Cannot read property 'ɵɵdefineInjectable' of undefined
above.Disabling Ivy and removing the interopNamespace leads to Angular compiler error
Cannot read property 'declarations' of null
Enabling Ivy and removing the interopNamespace does work as intended as @ratatoeskr666 mentioned.
I can confirm that
"esModuleInterop": false
does not help.Added branches with ng9 and ng10 configs on my repo.