fix(plugin-angular): update bundles and package entrypoints to support Ivy #994
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #735
Before
We produced two bundles:
/dist/es5/
- which contained ES5 + ES modules (import
but noclass
)/dist/esm/
- which contained ES2015 (import
andclass
)The various entry points we configured as follows:
The problem for the reproducible example supplied (with
"enableIvy": true
) was:It's worth noting that this problem seems to have gone away in more recent version. In an example which uses more recent versions (using newer versions of angular, again with Ivy enabled):
And the build is successful.
Problem
In the supplied example (which was using mostly angular
~8.2.14
dependencies plus@angular/cli ~8.3.25
) webpack is using themodule
target and expectingesm5
. However that bundle (/dist/esm/
) was actually compiled to ESM2015. This would seem to be correct according to this document, which gives an example:"module": "./fesm2015/core.js"
. However, when looking at how the packages are actually implemented, we see something different. Both@angular/[email protected]
and@angular/[email protected]
specify"module": "./fesm5/core.js",
rather than the./fesm2015/core.js
expected from the documented spec.It's worth noting also that neither of these package versions specify a
browser
field.After
If, rather than going with what the document says we replicate that
@angular/core
does, the problem is resolved for the failed Ivy test case (8.2.14
) and continues to work in the9.1.12
example and the existing E2E test.The changes are:
dist/es5
todist/esm5
to more accurately represent what it isdist/esm
todist/esm2015
to more accurately represent what it ismodule
andesm5
todist/esm5
instead ofdist/esm2015
to satisfy the8.2.14
test caseNote:
In the original commit I had created a third es5 proper bundle and pointed
browser
andmain
to that. This is what caused the E2E test case to fail. I did this because I assumedbrowser
should always point to code that is ready to be run in any supported browser (so we'd have to assume ES5) but it seems at least for angular esm5 is expected.With an ES5 bundle we got a build error:
and a runtime error:
It's worth noting that removing the
browser
field also fixed this error.Testing process
Build and start the app.
Check no build errors in console or runtime errors in browser
Clear
dist
,node_modules
and re-install withnpm i
In
tsconfig.json
add"enableIvy": true
toangularCompilerOptions
Build and start the app.
Check no build errors in console or runtime errors in browser
8.2.14
error reproduction9.1.12
example project (Start from https://angular.io/tutorial/toh-pt0 and install Bugsnag as per our docs)I suggest further testing is done on the various versions and varieties of angular apps and configurations we support.