Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser): Stub a .ts file to allow Angular AOT mode to recompile #539

Merged
merged 1 commit into from
May 20, 2019

Conversation

bengourley
Copy link
Contributor

@bengourley bengourley commented May 17, 2019

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:

ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve '@bugsnag/browser/dist/types/bugsnag' in '/Users/user/dev/ng-app/src/app'

Now switch over to this repository and checkout this branch.

Ensure the dependencies are installed and the standalone modules are built:

npm run bootstrap
npm run build

Prepare a tarball of the browser notifier:

cd packages/browser
npm pack

Switch back to the test-ng-app directory and install the tarball that was just created npm 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.

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.

Fixes #523
Copy link

@sazap10 sazap10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, works as expected.

@bengourley bengourley merged commit 2c78f8a into next May 20, 2019
@bengourley bengourley deleted the angular-aot-rebuild-fix branch May 20, 2019 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error When Rebuilding When Building With Ahead of Time Compilation
2 participants