Skip to content

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

@jwatte

Description

@jwatte

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions