Angular v10 issue with vendor packages
See original GitHub issueDescribe the bug Storybook does not load ES2015 bundles, leading to runtime errors in Angular v10 applications.
- Starting from v10, Angular ships only ES2015 bundles.
- Libraries typically ship both ES5 and ES2015 modules to remain compatible with Angular v8 and 9 (see APFv8, APFv10).
- Storybook does not include “es2015” entry points (note that
supportES2015
is always set tofalse
) in the loader config. - As a result, Angular is loaded as ES2015 and third-party libraries as ES5, leading to run-time errors such as functions attempting to extend classes.
To Reproduce
- Clone https://github.com/tsvetomir/ka-grid-1474492
- Run
npm ci
ingrid-app
- Run
npm run storybook
- See error in browser console:
ERROR TypeError: class constructors must be invoked with 'new'
ZoneAwareEventEmitter http://localhost:6006/vendors~main.f0580120cc2429d3a759.bundle.js:111214
GridComponent http://localhost:6006/vendors~main.f0580120cc2429d3a759.bundle.js:117347
createClass http://localhost:6006/vendors~main.f0580120cc2429d3a759.bundle.js:62526
The example uses the Kendo UI Grid, but presumably the issue is not limited to it.
Expected behavior The Storybook app should load ES2015 bundles, whenever available.
Screenshots
System:
System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
Binaries:
Node: 10.19.0 - /usr/local/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.14.5 - ~/.npm/bin/npm
Browsers:
Chrome: 83.0.4103.116
Firefox: 77.0.1
Safari: 13.1.1
npmPackages:
@storybook/angular: ^5.3.19 => 5.3.19
Additional context
The problem can be worked around by overriding the Webpack configuration in .storybook/webpack.config.js
.
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = async ({ config }) => {
const mainFields = [
'es2015',
'browser',
'module',
'main',
];
config.resolve.plugins = [new TsconfigPathsPlugin({
configFile: 'tsconfig.app.json',
mainFields
})];
config.resolve.mainFields = mainFields;
return config;
};
See the fix-modules branch for a runnable demo with this workaround.
Originally reported by @aishwaryasharma14
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Providing dependencies in modules - Angular
A provider is an instruction to the Dependency Injection system on how to obtain a value for a dependency. Most of the time,...
Read more >NG0201: No provider for {token} found! - Angular
You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping...
Read more >Building and serving Angular apps
This page discusses build-specific configuration options for Angular projects. Configuring application environmentslink. You can define different named ...
Read more >Angular workspace configuration
Resolve vendor packages source maps. boolean, false. hidden, Output source maps used for error reporting tools. boolean, false ...
Read more >ng build - Angular
Option Description Value Type Default Value
‑‑aot Build using Ahead of Time compilation. boolean true
‑‑base‑href Base url for the application being built. string
‑‑delete‑output‑path Delete...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Thanks for tips @shilman . I managed to fix it by changing this -> I also updated to latest version. In
storybook/tsconfig.json
@nicolae536 Try upgrading to 6.2. We just released a bunch of improvements there.