forge
forge copied to clipboard
Can't move the forge config files in any subdirectory
Pre-flight checklist
- [X] I have read the contribution documentation for this project.
- [X] I agree to follow the code of conduct that this project uses.
- [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
7.2.0
Electron version
v28.1.4
Operating system
MacOs 13.6.3
Last known working Electron Forge version
No response
Expected behavior
Electron should start with no errors and modules should be loaded correctly
Actual behavior
SyntaxError: Cannot use import statement outside a module
Steps to reproduce
I've generated a new project with
npm init electron-app@latest my-new-app -- --template=vite-typescript
The forge.config.ts
is located at the root of the project and if I launch the start script at this point everything works.
I want to move the config file into /tools/forge.config.ts
, and I do so by also modifying the packages.json:
"config": {
"forge": "./tools/forge.config.ts"
},
Now when I run the start script I get:
SyntaxError: Cannot use import statement outside a module
I've proceeded to also modify the tsconfig.json by adding the tools dir
"include": ["src", "tools"]
but nothing changed.
I've tried dozen of combination of these properties in tsconfig
"target": "ESNext",
"module": "commonjs",
I've also tried other combinations of the module
property inside packages.json but still no luck.
It seems things only work if I put back forge.config.ts
at the root of the project.
It this a misconfiguration on my side or some of the tools in the projects don't play well if I slightly modify the location of this file?
Additional information
No response
Can you provide a minimal reproduction repo?
Its not supported yet
It seems things only work if I put back forge.config.ts at the root of the project.
That's correct, we only look for a forge.config
file in the project root. The config.forge
property from package.json
is only used to specify the path to a Forge configuration file other than forge.config.js
in your project root (since #2993, you can technically have your Forge config in e.g. a yaml
file), not to set an arbitrary path within the project.
The
config.forge
property frompackage.json
is only used to specify the path to a Forge configuration file other thanforge.config.js
in your project root (since #2993, you can technically have your Forge config in e.g. ayaml
file), not to set an arbitrary path within the project.
Thanks, it's understood but totally counterintuitive 🙂 So I can have another forge config file BUT at the condition that it should still be in the main root?
I guess this should be specified in the docs, it was quite tedious to understand why simply moving a file breaks the entire workflow 🤔
Thanks for the explanation 👍