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

feat(vite): Add ability to switch Webpack for Vite on the web side #6967

Merged
merged 77 commits into from
Jan 10, 2023

Conversation

dac09
Copy link
Collaborator

@dac09 dac09 commented Nov 26, 2022

Experimental Vite Support 🎤

This PR does the following:

  • changes within the framework to make it Vite compatible (there's quite a lot here.... see full breakdown: https://www.notion.so/redwoodjs/Vite-RW-95f38a4e57ab4391b172b9d771b75104)
  • adds setup command to opt-in to using Vite. This will modify your project to make it Vite compatible
  • updates CLI to look for the bundler flag, and switch commands when running dev
  • find a way to make storybook run - currently failing because of the await import in DevFatalErrorPage
    Added experiments.topLevelAwait to storybook webpack config! Storybook is still running webpack

Importantly 👉 Everything should be backwards compatible (so no breaking changes for anyone remaining on webpack)


Outstanding tasks

  • Use config hook and setup the preset as a Vite plugin
  • Can we "inject" the entry point automatically instead of modifying index.html
  • Redirect to root doesn't seem to be working (i.e. refresh the page after navigating, you get a blank page)
  • Swap build command to vite
  • Fix prerender failures caused by top level await in FatalErrorPage

@Tobbe
Copy link
Member

Tobbe commented Nov 26, 2022

packages/cli-helpers/src/lib/installHelpers.ts Outdated Show resolved Hide resolved
packages/auth-providers-web/ambient.d.ts Outdated Show resolved Hide resolved
packages/internal/src/build/babel/web.ts Show resolved Hide resolved
packages/web/src/components/DevFatalErrorPage.tsx Outdated Show resolved Hide resolved
@@ -120,6 +120,9 @@ export function frameworkPackagesBins(packages = frameworkPkgJsonFiles()) {
if (!packageJson.bin) {
continue
}

// @TODO @MARK this interferes with having a single bin file
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jtoar wanted to chat to you about this and the bin aliasing we do!

…xperimental-vite-optin

* 'main' of github.com:redwoodjs/redwood:
  fix(deps): update dependency systeminformation to v5.16.9 (#7264)
  chore: rm experimental warning (#7262)
  feat: update auth docs in preparation for v4 (#7229)
  chore(deps): update dependency @testing-library/dom to v8.19.1 (#7261)
  fix: remove version from netlify decoder specifier
  fix(deps): update dependency @babel/traverse to v7.20.10 (#7260)
  fix(tests): Add boundary to Jest moduleNameMapper (#7252)
  Decoupling auth polishes (#7258)
  chore: try reverting babel resolution (#7257)
  Fix how the setup auth command checks for published versions (#7256)
  fix(deps): update dependency systeminformation to v5.16.8 (#7248)
  feat: bump node.js to 16, 18 (#7183)
  Decoupled auth setup: install handlers automatically (#7146)
  chore(deps): remove apparently unused, vulnerable package (#7244)
  chore(deps): update babel monorepo (#7249)
  fix: add babel resolution (#7250)
  chore(deps): update dependency jsonwebtoken to v9 [security] (#7247)
Remove node-polyfills, manually do it in DevFatalErrorPage instead
@dac09
Copy link
Collaborator Author

dac09 commented Dec 24, 2022

@jtoar ready for merge me thinks - addressed all comments, and fixed the issues @KrisCoulson and I found the other day! Also bumped to Vite 4. Note that I see an issue in storybook that looks like an unrelated issue: storybookjs/storybook#20383

BUT before merge, I need to know what version of "@babel/runtime-corejs3" should be - because yarn constriants --fix is automatically changing it to 7.20.6, and I'm not sure why.

It's still experimental ofcourse, and I will need to add fixes as we find bugs and shortcomings, but its now in a state where I think I'd like to get into more hands

FYI there's some stuff I've intentionally not done yet, e.g.

  • Vite dev and vite build should be called programatically
  • Prerendering images causes images to reload

Next step for me is to write up a guide for people to try over the holidays!

@dac09 dac09 added the fixture-ok Override the test project fixture check label Dec 24, 2022
@dac09
Copy link
Collaborator Author

dac09 commented Jan 9, 2023

@Tobbe would you like to review again/dismiss the old review please?

Want to get this into main (pushing up with merge conflicts resolved and new fixture shortly)

…xperimental-vite-optin

* 'main' of github.com:redwoodjs/redwood:
  Moves fastify.addContentTypeParser above configureFastify (#7178)
  Update to GraphQL Yoga v3 (#6727)
  setupHelpers: Add 'verbose' listr renderer support (#7285)
  authTasks: Sort imports (#7284)
  More setup tasks for better progress reporting (#7283)
  setupHelpers.test.ts: Remove unused arg (#7281)
  authTasks: Rename to addConfigToWebApp (#7279)
  chore(deps): update dependency supertokens-node to v12.1.4 (#7274)
  fix(deps): update dependency react-hook-form to v7.41.1 (#7269)
  fix(deps): update typescript-eslint monorepo to v5.47.1 (#7270)
  chore(deps): update dependency lerna to v6.3.0 (#7271)
  fix(deps): update dependency @types/node to v16.18.11 (#7275)
  authTasks: Refactor auth decoder arg handling (#7273)
  chore(deps): update dependency @types/jsonwebtoken to v9 (#7245)
  authTasks.ts: Extract addAuthDecoderToCreateGraphQLHandler (#7268)
  chore: update all contributors
Copy link
Member

Tobbe commented Jan 9, 2023

@dac09 I'll try to give it another look after our stand-up meeting later today

…xperimental-vite-optin

* 'main' of github.com:redwoodjs/redwood:
  Fix dbauth setup command in rebuild fixture (#7292)
@dac09 dac09 removed the fixture-ok Override the test project fixture check label Jan 9, 2023
Copy link
Member

@Tobbe Tobbe left a comment

Choose a reason for hiding this comment

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

I'm happy with your changes/replies to my comments, but please let @jtoar go through his comments too before you merge

@jtoar
Copy link
Contributor

jtoar commented Jan 10, 2023

I think we can see about listing esbuild as a dependency later. I'm inclined to just cause it's yarn's rules, but let's see what happens hoisting-wise once it's merged and the package is published. I'll also separate the handler after merge—I don't want to risk messing it up while it's in a workable state, and I'm only just getting back into things. One thing I'm wondering is if the toml change users have to make should just be a note logged to the console till the toml stuff is figured out. But that's also something we can do after merge.

Great stuff @dac09! I'll merge this so I can publish a canary version of the new package.

@jtoar jtoar merged commit a3e9480 into main Jan 10, 2023
@jtoar jtoar deleted the feat/dc-kc-experimental-vite-optin branch January 10, 2023 03:13
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Jan 10, 2023
@redwoodjs-bot
Copy link

redwoodjs-bot bot commented Jan 10, 2023

🔔 @jtoar, @Tobbe—I couldn't cherry pick this one. If you want it in the next release, you'll have to cherry pick it manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature This PR introduces a new feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants