Skip to content
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

rush-init-project-plugin doesn't work with ESM package.json #18

Open
jwatte opened this issue Sep 9, 2024 · 1 comment
Open

rush-init-project-plugin doesn't work with ESM package.json #18

jwatte opened this issue Sep 9, 2024 · 1 comment

Comments

@jwatte
Copy link

jwatte commented Sep 9, 2024

I want a package.json that's pre-defined in my template directory.
This package.json specifies "type":"module"
But the init.config.ts script (or .js script) live in this same directory, and thus node picks up this configuration.
This means that I get an error about trying to use require() to load ESM modules:

Must use import to load ES Module: /Users/jwatte/github.com/reve-ai/reve-core/common/_templates/backend-service/init.config.ts
require() of ES modules is not supported.
require() of /Users/jwatte/github.com/reve-ai/reve-core/common/_templates/backend-service/init.config.ts from /Users/jwatte/github.com/reve-ai/reve-core/common/autoinstallers/rush-tools/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/rush-init-project-plugin/lib/logic/TemplateConfiguration.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /Users/jwatte/github.com/reve-ai/reve-core/common/_templates/backend-service/package.json.
@jwatte
Copy link
Author

jwatte commented Sep 9, 2024

To be a little more clear:
It's my template that has a package.json with "type":"module"
This template also has an init.config.js (or .ts)
Node then treats this as an ES module but the rush-plugins code is trying to load it with require().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant