Skip to content

Can't move the forge config files in any subdirectory #3471

@LeonardoGentile

Description

@LeonardoGentile

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions