fix(browser): Stub a .ts file to allow Angular AOT mode to recompile #539
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.
In Angular's AOT mode, the first full build would work but an incremental build upon making a change
would fail with an error that it couldn't locale the bugsnag browser types module. By generating an
empty bugsnag.ts file in the browser/dist/types directory, Angular is convinced that it's ok and it
all compiles and runs correctly.
Additionally this removes the stubbed types on the Bugsnag object – in none of my test permutations were these needed.Update: I found that it was required in the end.Fixes #523
Testing
Create a new angular app
npx ng new test-ng-app
and integrate Bugsnag according to the docs.Run it with
ng serve --aot
and once it's running, save one of the source files to trigger a rebuild. Notice this error:Now switch over to this repository and checkout this branch.
Ensure the dependencies are installed and the standalone modules are built:
Prepare a tarball of the browser notifier:
Switch back to the
test-ng-app
directory and install the tarball that was just creatednpm install ../../path-to-bugsnag-js/packages/browser/bugsnag-browser-6.2.0.tgz
.Run the app again with
ng serve --aot
and once it's running, save one of the source files to trigger a rebuild. Notice that the error does not occur.