Skip to content

Vite 2.7 compatibility#236

Merged
jplhomer merged 13 commits intomainfrom
jl-test-vite-270
Dec 7, 2021
Merged

Vite 2.7 compatibility#236
jplhomer merged 13 commits intomainfrom
jl-test-vite-270

Conversation

@jplhomer
Copy link
Copy Markdown
Contributor

@jplhomer jplhomer commented Nov 15, 2021

This PR is a test suite against Vite 2.7 betas to ensure Hydrogen is compatible with the latest SSR changes.

Stackblitz: https://stackblitz.com/edit/hydrogen-da5gft?file=package.json

@frandiox
Copy link
Copy Markdown
Contributor

frandiox commented Nov 16, 2021

Looks like the ESM errors are fixed in vitejs/vite#5693
I still get sourcemap warnings, though. But that's a different issue.

@jplhomer
Copy link
Copy Markdown
Contributor Author

Seeing E2E tests fail now: https://github.com/Shopify/hydrogen/runs/4226509082?check_suite_focus=true

Seeing this locally when running the dev server:

export {default} from './dist/esnext/entry-server';
^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1025:15)
    at Module._compile (node:internal/modules/cjs/loader:1059:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:201:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)

Do we need to do something special to denote our exports as ESM?

@frandiox
Copy link
Copy Markdown
Contributor

frandiox commented Nov 17, 2021

@jplhomer The dev project works for me. Can you try with --force, or reinstalling node_modules? 🤔

The issue we have with the e2e for the worker is likely related to this line: https://github.com/vitejs/vite/blob/96664469e49d44f8c628bf0310bdd03d1c4556de/packages/vite/src/node/plugins/ssrRequireHook.ts#L50

That require ends up in our built worker.js. And of course, require doesn't exist in a worker environment.

@frandiox
Copy link
Copy Markdown
Contributor

frandiox commented Nov 17, 2021

After the last next commit, e2e starts passing when using Vite's main branch. That should be released in a few hours as beta.7 .

@frandiox
Copy link
Copy Markdown
Contributor

@jplhomer all green! 🟢 🎉

@jplhomer
Copy link
Copy Markdown
Contributor Author

DOPE. Thanks for all of your work @frandiox (and Vite team, of course).

@frandiox
Copy link
Copy Markdown
Contributor

frandiox commented Dec 7, 2021

@jplhomer 2.7.0 released and looks like it works well :)

Should we merge this?

@jplhomer jplhomer marked this pull request as ready for review December 7, 2021 15:13
@jplhomer jplhomer changed the title tracking: Vite 2.7 compatibility Vite 2.7 compatibility Dec 7, 2021
@jplhomer
Copy link
Copy Markdown
Contributor Author

jplhomer commented Dec 7, 2021

Let's do it! Will merge when CI passes.

@jplhomer jplhomer merged commit 75bc546 into main Dec 7, 2021
@jplhomer jplhomer deleted the jl-test-vite-270 branch December 7, 2021 15:29
rafaelstz pushed a commit to rafaelstz/hydrogen that referenced this pull request Mar 4, 2023
* Refine tailwind classes for sort UI

* Update SortFilter.tsx
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.

2 participants