Script imports are modules by default
See original GitHub issueπ Bug report
Command (mark with an x
)
- build
- serve
Is this a regression?
Yes, the previous version in which this bug was not present was: 12.2.13Description
Now that dynamic imports are of type="module"
by default this breaks imports of legacy libraries that were not built with strict mode in mind.
We are using calentim datepicker in a lazy loaded module(also loading the library with dynamic import) in the project and with the transition to angular 13 and specifically with the change of default webpack output to produce script tags with the type module in https://github.com/angular/angular-cli/commit/f53bf9dc21ee9aa8a682b8a82ee8a9870fa859e1 the library breaks as it is not written in strict mode.
I understand the desire to move to modules by default, but would like to have an option to import legacy code as 'text/javascript'
.
This feels like a breaking change that didnβt get a mention in https://update.angular.io notes either.
π¬ Minimal Reproduction
await import('./legacy/library.js')
Using the library will brake during runtime if it violates strict mode.
π Your Environment
ng version
Angular CLI: 13.0.2
Node: 16.13.0
Package Manager: npm 8.1.0
OS: win32 x64
Angular: 13.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1300.2
@angular-devkit/build-angular 13.0.2
@angular-devkit/core 13.0.2
@angular-devkit/schematics 13.0.2
@angular/cli 13.0.2
@schematics/angular 13.0.2
rxjs 6.6.7
typescript 4.4.4
Anything else relevant? I understand the ability to provide custom builder in angular.json, but would like to avoid it as it is a large undertaking to keep it updated between angular releases than being able to configure this some other way.
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (6 by maintainers)
Top GitHub Comments
Yes, that is totally understandable.
I just thought dropping support for modules would be something that would be important to mention in the change log.
Would have appreciated a warning. π
Otherwise, I agree with browser support approach.
This is the only issue I found related to this subject, apologies to hijack it.
We recently hit a critical breaking change with Angular 13 and older SmartTV browsers. We have some customers using Samsung TVs from 2018. Those TVs use Chromium 57 and have not had an update to the browser version, even though they had firmware updates as recent as 2021.
Chrome 57 is from before the time of
script type="module"
, and we already updated our app - not seeing anything concerning in the list of breaking changes (except dropping support for IE 11, but that didnβt seem relevant).Is there any way to force Angular 13 to create normal/non-module scripts and
script
tags?Or at least, could you point me to where this change was made? Iβd be interested in trying to revert it in a fork so we can get unblocked.