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

Better prerender crash message when error originates in node_modules/ #1426

Merged
merged 3 commits into from Apr 15, 2022

Conversation

VanTanev
Copy link
Contributor

What kind of change does this PR introduce?

Improves the error message when prerender fails because of code that ran in node_modules/

Before:
image (17)

After:
image

Did you add tests for your changes?

No

Summary

This improves the prerender error message in cases like the following:

import { createBrowserHistory } from 'history'

<App>
  <Router history={createBrowserHistory()}> // breaks prerendering
  // [...]

Fixed code:

import { createBrowserHistory, createMemoryHistory } from 'history'

<App>
  <Router history={
    typeof window !== 'undefined' 
        ? createBrowserHistory()
        : createMemoryHistory()
  }> 
  // [...]

Does this PR introduce a breaking change?

No

Other information

Environment Info:
  System:
    OS: Linux 4.15 Ubuntu 16.04.7 LTS (Xenial Xerus)
    CPU: (16) x64 Intel(R) Core(TM) i9-9900KS CPU @ 4.00GHz
  Binaries:
    Node: 14.8.0 - ~/.nvm/versions/node/v14.8.0/bin/node
    Yarn: 1.21.1 - /usr/bin/yarn
    npm: 6.14.7 - ~/.nvm/versions/node/v14.8.0/bin/npm
  Browsers:
    Chrome: 85.0.4183.102
    Firefox: 80.0.1
  npmPackages:
    preact: ^10.4.8 => 10.4.8 
    preact-cli: ^3.0.1 => 3.0.1 
    preact-render-to-string: ^5.1.10 => 5.1.10 
    preact-router: ^3.2.1 => 3.2.1 

@VanTanev VanTanev requested a review from a team as a code owner September 15, 2020 11:07
@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2020

🦋 Changeset detected

Latest commit: 27fd7b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@VanTanev
Copy link
Contributor Author

Is the PR author supposed to add the changeset?

@rschristian rschristian force-pushed the better-prerender-crash-message branch from d3c68fd to 27fd7b3 Compare April 15, 2022 07:25
Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

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

Sorry for the super long delay in this. Great work! Really appreciate it.

@rschristian rschristian enabled auto-merge (squash) April 15, 2022 07:27
@rschristian rschristian merged commit 7d33cd1 into preactjs:master Apr 15, 2022
@preact-bot preact-bot mentioned this pull request Apr 15, 2022
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.

None yet

2 participants