-
-
Notifications
You must be signed in to change notification settings - Fork 517
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: esm forge.config.js support #3358
Conversation
Of course, I understand that it is better to (1) update typescript (2) update target to |
I think the failing Windows tests are not related to the changes. |
Related #3129 |
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.
We cant ship code that depends on string templated eval, that's neither safe nor generally good practice
@MarshallOfSound maybe you know how to make quite old typescript to not compile Or if you plan to upgrade typescript and compiled module type it should be pretty easy. |
Make a plain JS file that exports a helper that uses the dynamic import method. Not pretty but better than eval imo |
@MarshallOfSound if dynamic import is in js file it is compiled to require.... I need help to figure it out. return Promise.resolve().then(() => __importStar(require(path))); |
@MarshallOfSound I think I was able to get it to work with the current version of ts. Could you please check the current implementation? |
Windows tests are fixed! |
@MarshallOfSound @erikian @erickzhao what can I do to ship this feature? |
@MarshallOfSound @erikian @erickzhao it is me again 😉 What should I do to ship this feature? |
hi, what's the update on this progress? |
Looks like it doesn't work with forge.config. The
|
I must be crazy or something, but I am trying to convert my $ npx electron-forge package
✔ Checking your system
✖ Preparing to package application
› require() of ES Module C:\Users\felip\repos\clipboard-sync\forge.config.js from
C:\Users\felip\repos\clipboard-sync\node_modules\@electron-forge\core\dist\util\forge-config.js not supported.
Instead change the require of forge.config.js in
C:\Users\felip\repos\clipboard-sync\node_modules\@electron-forge\core\dist\util\forge-config.js to a dynamic
import() which is available in all CommonJS modules.
◼ Running packaging hooks
◼ Packaging application
◼ Running postPackage hook
Failed to load: C:\Users\felip\repos\clipboard-sync\forge.config.js
An unhandled rejection has occurred inside Forge:
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\felip\repos\clipboard-sync\forge.config.js from C:\Users\felip\repos\clipboard-sync\node_modules\@electron-forge\core\dist\util\forge-config.js not supported.
Instead change the require of forge.config.js in C:\Users\felip\repos\clipboard-sync\node_modules\@electron-forge\core\dist\util\forge-config.js to a dynamic import() which is available in all CommonJS modules.
at exports.default (C:\Users\felip\repos\clipboard-sync\node_modules\@electron-forge\core\dist\util\forge-config.js:140:26)
at async C:\Users\felip\repos\clipboard-sync\node_modules\@electron-forge\core\dist\api\package.js:80:35
at async _Task.taskFn (C:\Users\felip\repos\clipboard-sync\node_modules\@electron-forge\tracer\dist\index.js:58:20)
at async _Task.run (C:\Users\felip\repos\clipboard-sync\node_modules\listr2\dist\index.cjs:2063:11) Am I missing something? |
I see now. The loader blindly ignores all errors when trying to import my config and then fallbacks to requiring. I had an error in my config, therefore it was entering in the fallback. |
Just in case others stumble upon this: I had to change: import MakerSquirrel from "@electron-forge/maker-squirrel"; To: import { MakerSquirrel } from "@electron-forge/maker-squirrel"; |
Summarize your changes:
This tiny PR adds ESM config support. Test added. Closes #3350
It is not a breaking change. Be ready for Electron 28 with ESM support! 💯