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

Remove DevFatalErrorPage import when building #8648

Merged

Conversation

Tobbe
Copy link
Member

@Tobbe Tobbe commented Jun 17, 2023

This lets us get rid of the commonjs plugin for Vite.
I went with the "alternative approach" from the description below

From initial description

This is the cause of a lot of issues with Webpack and Vite cross compatibility

Video description:
https://s.tape.sh/NZPq70HZ?s=1.25

We can use https://webpack.js.org/configuration/resolve/ and equivalent in vite to solve this.

i.e. do a normal import, but during build resolve it to null on both webpack and vite - so that its not included in the production build

Subtasks:

  • Modify the CRWA template to import DevFatalErrorPage like normal
    import { DevFatalErrorPage as RedwoodDevFatalErrorPage } from '@redwoodjs/web/dist/components/DevFatalErrorPage'
  • Configure webpack to not include the dev fatal error page during build
  • Configure Vite to not include this page in the bundle during build
  • Validate prerender
  • Remove commonjs plugin from Vite

⚠️ Alternative approach

Use babel to set imports from @redwoodjs/web/dist/components/DevFatalErrorPage to an empty module somehow. This will work in all cases - Vite, Webpack and prerender

@Tobbe Tobbe marked this pull request as ready for review June 17, 2023 06:31
@Tobbe Tobbe added the release:chore This PR is a chore (means nothing for users) label Jun 17, 2023
@Tobbe Tobbe enabled auto-merge (squash) June 18, 2023 11:13
@Tobbe Tobbe merged commit 78c33b2 into redwoodjs:main Jun 18, 2023
28 checks passed
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Jun 18, 2023
@Tobbe Tobbe deleted the tobbe-remove-dev-fatal-error-page-when-building branch June 18, 2023 11:44
@@ -76,7 +76,12 @@ export const getWebSideBabelPlugins = (
'rwjs-web-auto-import',
],
['babel-plugin-graphql-tag', undefined, 'rwjs-babel-graphql-tag'],
// === Handling redwood "magic"
process.env.NODE_ENV !== 'development' && [
Copy link
Collaborator

@dac09 dac09 Jun 19, 2023

Choose a reason for hiding this comment

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

I would have kept the logic inside the plugin - as in always run the plugin, but the plugin doesn't do anything if its not in dev.

But just preference!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:chore This PR is a chore (means nothing for users)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants