-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): address @ionic/angular bundle size issue (#5705)
This fixes an issue where when @ionic/angular was built using Stencil and then used in an angular project it would produce much larger bundle sizes than it had previously. This issue started appearing in Stencil v4.17.x, after we switched to using esbuild for our production builds. The issue occurred because of how bundles in `internal/` were depending on code in `mock-doc/`. In particular, in `src/runtime/dom-extras.ts` we had an import from `@stencil/core/mock-doc`. In our bundles this was being correctly externalized, so that `internal/client/index.js` for instance would import from `'../../mock-doc/index.cjs'`, but the problem is that when an Angular project then tried to bundle this file later it would not tree-shake the import properly and the whole contents of mock-doc would be injected into the bundle, bloating it by 400kb or so. This is because esbuild, which `ng build` uses under the hood, does not support tree-shaking in commonjs modules. See here for details: https://esbuild.github.io/api/#tree-shaking The simplest fix for this is to add the `NODE_TYPES` enum to `src/utils/constants.ts` so that the runtime does not need to have any dependency on `mock-doc` at all.
- Loading branch information
1 parent
aea6275
commit 0a7becc
Showing
7 changed files
with
33 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters