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
build: switch from ts-node to esbuild-register #3579
Conversation
"scripts": {
// ...
"start:preload": "cross-env NODE_ENV=development NODE_OPTIONS=\"-r esbuild-register\" webpack --config ./.erb/configs/webpack.config.preload.dev.ts",
"start:renderer": "cross-env NODE_ENV=development NODE_OPTIONS=\"-r esbuild-register\" webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
// ...
}, If not set, an error will occur when $ node -r esbuild-register ./.erb/scripts/check-port-in-use.js && npm run start:renderer
> nvm-desktop@2.6.2 start:renderer
> cross-env NODE_ENV=development webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts
[webpack-cli] Failed to load '/Users/******/Documents/Electron/nvm-desktop/.erb/configs/webpack.config.renderer.dev.ts' config
[webpack-cli] /Users/******/Documents/Electron/nvm-desktop/.erb/scripts/check-node-env.js:1
import chalk from 'chalk';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1153:20)
at Module._compile (node:internal/modules/cjs/loader:1205:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at extensions..js (/Users/******/Documents/Electron/nvm-desktop/node_modules/esbuild-register/dist/node.js:4838:24)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at require (node:internal/modules/helpers:130:18)
at Object.<anonymous> (/Users/******/Documents/Electron/nvm-desktop/.erb/configs/webpack.config.renderer.dev.ts:12:26)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. The Thank you for your work. 🌹 |
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts", | ||
"start": "node -r esbuild-register ./.erb/scripts/check-port-in-use.js && npm run start:renderer", | ||
"start:main": "cross-env NODE_ENV=development NODE_OPTIONS=\"--loader esbuild-register/loader -r esbuild-register\" electronmon .", | ||
"start:preload": "cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.preload.dev.ts", |
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.
For me it wasn't enough to leave this as-is; instead I had to add the NODE_OPTIONS=\"--loader esbuild-register/loader -r esbuild-register\"
here as well (basically anywhere webpack
was called). But this may be due to my fork which has already deviated from this project.
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.
Ok, I realize this is the same comment as #3579 (comment).
And yes, release/app/package.json
also requires changes!
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.
@slhck thanks for the input. I did the same changes & it worked for me with electron version 28.
Closing as this isn't fully baked (switching to |
Fixes #3568.
ts-node
is having issues working with the latest versions of Node.js - since this repo is using transpile-only mode anyway, switch toesbuild-register
which isn't having those issues.