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

Time to upgrade again - semantic-release is now ESM :/ #292

Open
kf6kjg opened this issue Mar 14, 2023 · 0 comments
Open

Time to upgrade again - semantic-release is now ESM :/ #292

kf6kjg opened this issue Mar 14, 2023 · 0 comments

Comments

@kf6kjg
Copy link

kf6kjg commented Mar 14, 2023

The base repo has converted to ESM. This is causing me some headaches:

  1. My config file is TS that's compiled to JS. The only TypeScript types that exist are for @types/semantic-release which exports as ESM.
  2. SRP is still CommonJS and thus fails with the following error:
An error occurred while running semantic-release: Error [ERR_REQUIRE_ESM]: require() of ES Module /__w/libraries/libraries/packages/eslint-config/.releaserc.mjs not supported.
    root: Instead change the require of /__w/libraries/libraries/packages/eslint-config/.releaserc.mjs to a dynamic import() which is available in all CommonJS modules.
    root:     at /__w/libraries/libraries/node_modules/semantic-release-plus/lib/get-config.js:30:32
    root:     at Array.reduce (<anonymous>)
    root:     at module.exports (/__w/libraries/libraries/node_modules/semantic-release-plus/lib/get-config.js:29:33)
    root:     at async module.exports (/__w/libraries/libraries/node_modules/semantic-release-plus/index.js:357:34)
    root:     at async module.exports (/__w/libraries/libraries/node_modules/semantic-release-plus/cli.js:102:5) {
    root:   code: 'ERR_REQUIRE_ESM'
    root: }
    root: Error [ERR_REQUIRE_ESM]: require() of ES Module /__w/libraries/libraries/packages/eslint-config/.releaserc.mjs not supported.
    root: Instead change the require of /__w/libraries/libraries/packages/eslint-config/.releaserc.mjs to a dynamic import() which is available in all CommonJS modules.
    root:     at /__w/libraries/libraries/node_modules/semantic-release-plus/lib/get-config.js:30:32
    root:     at Array.reduce (<anonymous>)
    root:     at module.exports (/__w/libraries/libraries/node_modules/semantic-release-plus/lib/get-config.js:29:33)
    root:     at async module.exports (/__w/libraries/libraries/node_modules/semantic-release-plus/index.js:357:34)
    root:     at async module.exports (/__w/libraries/libraries/node_modules/semantic-release-plus/cli.js:102:5) {
    root:   code: 'ERR_REQUIRE_ESM'
    root: }

There are some possible workarounds:

  1. Convert to CommonJS and use TypeScript import assertions - an ugly workaround, and currently requires the TS nightly build.
  2. Convert to CommonJS and tell TS to forget about it via // eslint-disable-next-line @typescript-eslint/ban-ts-comment and // @ts-ignore next just before the import of the types from semantic-release. This is what I'm going with ATM to get pas this issue.
  3. Write the config file in raw JS. Eww. No. Been there, fought the bugs.

I'm using JS config files to help support a home-brewed merging "extends" functionality from a central config that really helped with centralizing my release config without compromising the per-package needs.

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