Skip to content

fix(@angular-devkit/build-angular): resolve and load sourcemaps during prerendering to provide better stacktraces #26033

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

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Oct 13, 2023

With this commit when running a build with sourcemaps enabled we enable Node.js Sourcemap support for stack traces. See: https://nodejs.org/dist/latest/docs/api/cli.html#--enable-source-maps for more information about this feature.

Before

ERROR ReferenceError: window is not defined
    at new _AppComponent (file:///chunk-HFZN2HE2.mjs:41631:19)
    at NodeInjectorFactory.AppComponent_Factory [as factory] (file:///chunk-HFZN2HE2.mjs:41635:12)
    at getNodeInjectable (file:///chunk-HFZN2HE2.mjs:6104:38)
    at createRootComponent (file:///chunk-HFZN2HE2.mjs:10446:31)
    at ComponentFactory.create (file:///chunk-HFZN2HE2.mjs:10348:19)
    at _ApplicationRef.bootstrap (file:///chunk-HFZN2HE2.mjs:13247:40)
    at file:///chunk-HFZN2HE2.mjs:12938:20
    at _ZoneDelegate.invoke (file:///chunk-HFZN2HE2.mjs:320:158)
    at Object.onInvoke (file:///chunk-HFZN2HE2.mjs:8562:25)
    at _ZoneDelegate.invoke (file:///chunk-HFZN2HE2.mjs:320:46)

Now

ERROR ReferenceError: window is not defined
    at constructor (/usr/xxxx/src/app/app.component.ts:16:17)
    at NodeInjectorFactory.AppComponent_Factory (/usr/xxxx/src/app/app.component.ts:17:3)
    at getNodeInjectable (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:4166:38)
    at createRootComponent (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:14064:31)
    at ComponentFactory.create (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:13931:19)
    at _ApplicationRef.bootstrap (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:30650:40)
    at <anonymous> (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:30163:20)
    at _ZoneDelegate.invoke (/usr/xxxx/node_modules/zone.js/fesm2015/zone-node.js:344:158)
    at Object.onInvoke (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:10964:25)
    at _ZoneDelegate.invoke (/usr/xxxx/node_modules/zone.js/fesm2015/zone-node.js:344:46)

Closes #26013

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: rc This PR is targeted for the next release-candidate labels Oct 13, 2023
@alan-agius4 alan-agius4 force-pushed the sm-server-builds branch 3 times, most recently from b12a6c8 to 50a8415 Compare October 13, 2023 09:38
@alan-agius4 alan-agius4 requested a review from clydin October 13, 2023 10:01
…g prerendering to provide better stacktraces

With this commit when running a build with sourcemaps enabled we enable Node.js Sourcemap support for stack traces.
See: https://nodejs.org/dist/latest/docs/api/cli.html#--enable-source-maps for more information about this feature.

Before
```
ERROR ReferenceError: window is not defined
    at new _AppComponent (file:///chunk-HFZN2HE2.mjs:41631:19)
    at NodeInjectorFactory.AppComponent_Factory [as factory] (file:///chunk-HFZN2HE2.mjs:41635:12)
    at getNodeInjectable (file:///chunk-HFZN2HE2.mjs:6104:38)
    at createRootComponent (file:///chunk-HFZN2HE2.mjs:10446:31)
    at ComponentFactory.create (file:///chunk-HFZN2HE2.mjs:10348:19)
    at _ApplicationRef.bootstrap (file:///chunk-HFZN2HE2.mjs:13247:40)
    at file:///chunk-HFZN2HE2.mjs:12938:20
    at _ZoneDelegate.invoke (file:///chunk-HFZN2HE2.mjs:320:158)
    at Object.onInvoke (file:///chunk-HFZN2HE2.mjs:8562:25)
    at _ZoneDelegate.invoke (file:///chunk-HFZN2HE2.mjs:320:46)
```

Now
```
ERROR ReferenceError: window is not defined
    at constructor (/usr/xxxx/src/app/app.component.ts:16:17)
    at NodeInjectorFactory.AppComponent_Factory (/usr/xxxx/src/app/app.component.ts:17:3)
    at getNodeInjectable (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:4166:38)
    at createRootComponent (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:14064:31)
    at ComponentFactory.create (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:13931:19)
    at _ApplicationRef.bootstrap (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:30650:40)
    at <anonymous> (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:30163:20)
    at _ZoneDelegate.invoke (/usr/xxxx/node_modules/zone.js/fesm2015/zone-node.js:344:158)
    at Object.onInvoke (/usr/xxxx/node_modules/@angular/core/fesm2022/core.mjs:10964:25)
    at _ZoneDelegate.invoke (/usr/xxxx/node_modules/zone.js/fesm2015/zone-node.js:344:46)
```

Closes angular#26013
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 16, 2023
@alan-agius4 alan-agius4 merged commit 0f45e21 into angular:main Oct 16, 2023
@alan-agius4 alan-agius4 deleted the sm-server-builds branch October 16, 2023 06:37
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

application builder: non-informative exceptions with prerender: true
2 participants