-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,7 +202,16 @@ const main = async () => { | |
) | ||
.addOption(new program.Option('--noHMR', 'disable the client-side hot module replacement')) | ||
.action(async ({inspect, noHMR}) => { | ||
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'), | ||
'..', | ||
'..', | ||
'..', | ||
'.bin', | ||
'babel-node' | ||
) | ||
execSync(`${babelNode} ${inspect ? '--inspect' : ''} ${resolvedSSRPath}`, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think require.resolve finds the binaries from |
||
env: { | ||
...process.env, | ||
...(noHMR ? {HMR: 'false'} : {}) | ||
|
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 thanbabel-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 bothbabel-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.