Skip to content

[bug] @changesets/cli running cjs file, even though the package is a module #1510

@hirasso

Description

@hirasso

Affected Packages

@changesets/cli

The Problem

Context

I'm trying to create a script that runs on commit. Following the documentation, I have added this to my changesets config.json:

{
"commit": ["../scripts/commit.js", { "customOption": true }]
}

When using es6 syntax inside commit.js, pnpm changeset fails because it is run in a .cjs file. Relevant output:

❯ pnpm changeset
🦋  What kind of change is this for rh-admin-utils? (current version is 2.3.5) · patch
🦋  Please enter a summary for this change (this will be in the changelogs).
🦋    (submit empty line to open external editor)
🦋  Summary · goo bar baz
🦋  
🦋  === Summary of changesets ===
🦋  patch:  rh-admin-utils
🦋  
🦋  Is this your desired changeset? (Y/n) · true
🦋  error Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/[...]/scripts/commit.js from /Users/[...]/node_modules/.pnpm/@[email protected]/node_modules/@changesets/cli/dist/changesets-cli.cjs.js not supported.

I've seen that there exists an esm version just besides the changesets-cli.cjs.js version. My package has {"type": "module"}.

Proposed solution

I don't know really :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions