-
Notifications
You must be signed in to change notification settings - Fork 144
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
Use babel node for local development to support ES6 import #1278
Conversation
Signed-off-by: Kevin He <[email protected]>
execSync(`node${inspect ? ' --inspect' : ''} ${resolvedSSRPath}`, { | ||
// We use @babel/node instead of node because we want to support ES6 import syntax | ||
const babelNode = p.join( | ||
require.resolve('webpack'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why webpack
rather than babel-node
itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because for some reason, babel packages have weird namings, i think babel node was called babel-node
and since a major version (i forgot exactly which version), they moved to scoped packages like @babel/node
.
However, require.resolve
doesn't work for both babel-node
nor @babel/node
, so i had to fall back to webpack...
I also don't understand why all pwa-kit-dev commands resolves to bin using path.join('..','..','..')
, but i just followed the existing pattern...
if anyone knows the reason, pls let me know.
'.bin', | ||
'babel-node' | ||
) | ||
execSync(`${babelNode} ${inspect ? '--inspect' : ''} ${resolvedSSRPath}`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just npx babel-node
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think require.resolve finds the binaries from pwa-kit-dev
correctly, and that causes a delay for the start
command when you run it the first time, cuz npx will try to install it...
Description
In PWA Kit V2/V3, the server side code
ssr.js
(or any files imported fromssr.js
) are Commonjs modules. However, in V1, ES6 import statements were supported. Some customers encountered difficulties upgrading from v1 to v2 because of the non-compatible changes introduced in V2.This PR explores the options to bring back ES6 import statement to
ssr.js
.TODO:
Rollout plan
Types of Changes
Changes
pwa-kit-dev start
How to Test-Drive This PR
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization