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

Feat: Support for New Semantic Release Version. #137

Closed
wants to merge 32 commits into from

Conversation

w4rlock
Copy link

@w4rlock w4rlock commented Mar 10, 2023

Please

I need to merge theses changes.

Theses changes resolve next error (ERR_REQUIRED_ESM)

  • Support for semantic release version
  • Support for Node 18
  • Fix Unit Test
  • Fix Code Linters
  • Tools integration for code styling (prettier, eslint)

@achingbrain
Copy link

achingbrain commented May 3, 2023

I think this might need a further fix in https://github.com/semantic-release/semantic-release - I'm experimenting with a fork containing this PR and pmowrer/semantic-release-plugin-decorators#31 and get:

[11:04:38 AM] [semantic-release] › ✘  An error occurred while running semantic-release: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/helia-strings/helia-strings/node_modules/semantic-release-monorepo/src/index.js from /home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js not supported.
Instead change the require of index.js in /home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js to a dynamic import() which is available in all CommonJS modules.
    at file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js:38:32
    at async default (file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js:36:11)
    at async Module.default (file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/index.js:271:34)
    at async default (file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/cli.js:55:5) {
  code: 'ERR_REQUIRE_ESM'
}

@pdecat
Copy link

pdecat commented May 3, 2023

I think this might need a further fix in https://github.com/semantic-release/semantic-release - I'm experimenting with a fork containing this PR and pmowrer/semantic-release-plugin-decorators#31 and get:

[11:04:38 AM] [semantic-release] › ✘  An error occurred while running semantic-release: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/helia-strings/helia-strings/node_modules/semantic-release-monorepo/src/index.js from /home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js not supported.
Instead change the require of index.js in /home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js to a dynamic import() which is available in all CommonJS modules.
    at file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js:38:32
    at async default (file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/lib/get-config.js:36:11)
    at async Module.default (file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/index.js:271:34)
    at async default (file:///home/runner/work/helia-strings/helia-strings/node_modules/semantic-release/cli.js:55:5) {
  code: 'ERR_REQUIRE_ESM'
}

@achingbrain I went down the same rabbit hole, and discovered that according to the comment in
semantic-release/semantic-release#2569, extends needs to:

references to plugin files in configs need to include the file extension because of executing in an ESM context

So the following configuration works:

{
  "extends": "./node_modules/semantic-release-monorepo/package.json"
}

Not sure why they didn't replace createRequire/require() by import() as it seems to work for both CommonJS and ESM:

diff --git a/lib/get-config.js b/lib/get-config.js
index 429577e..b75e375 100644
--- a/lib/get-config.js
+++ b/lib/get-config.js
@@ -1,6 +1,5 @@
 import { dirname, resolve } from "node:path";
 import { fileURLToPath } from "node:url";
-import { createRequire } from "node:module";

 import { castArray, isNil, isPlainObject, isString, pickBy } from "lodash-es";
 import { readPackageUp } from "read-pkg-up";
@@ -14,7 +13,6 @@ import { parseConfig, validatePlugin } from "./plugins/utils.js";

 const debug = debugConfig("semantic-release:config");
 const __dirname = dirname(fileURLToPath(import.meta.url));
-const require = createRequire(import.meta.url);

 const CONFIG_NAME = "release";

@@ -35,7 +33,7 @@ export default async (context, cliOptions) => {
     options = {
       ...(await castArray(extendPaths).reduce(async (eventualResult, extendPath) => {
         const result = await eventualResult;
-        const extendsOptions = require(resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath));
+        const extendsOptions = import(resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath));

         // For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path,
         // so those plugin will be loaded relative to the config file

@bryanjtc
Copy link
Contributor

Any update on this?

@Julian-B90
Copy link

@pmowrer can you merge this?

@jcapogna
Copy link

jcapogna commented Jul 4, 2023

Can this get merged? This is a pretty big issue as it forces users of semantic-release-monorepo to downgrade plugins that are now ESM only.

@bryanjtc
Copy link
Contributor

bryanjtc commented Jul 4, 2023

@pmowrer

@jcapogna
Copy link

jcapogna commented Jul 4, 2023

FYI - I created #138 to document which plugins need to be downgraded due to lack of ESM support in semantic-release-monorepo.

@pmowrer
Copy link
Owner

pmowrer commented Jul 5, 2023

Even if this was merged, the build is broken. This project relied on travis-ci but that appears to have been busted a long time ago when travis-ci underwent big changes. The build process needs to be moved to github actions

@jcapogna
Copy link

jcapogna commented Jul 5, 2023

That's good context @pmowrer. I also don't even know if this change works or solves the problems it needs to.

Do you think you could create an issue for fixing the build and explaining what needs to be done? Then maybe someone in the community can work on it. Not sure if that requires adding some users with higher permissions to this project to set up GitHub actions.

EvHaus added a commit to GlobexDesignsInc/eslint-config-globex that referenced this pull request Jul 19, 2023
MatthewPattell added a commit to Lomray-Software/semantic-release-monorepo that referenced this pull request Jul 28, 2023
@FrederickEngelhardt
Copy link

Any ETA on this being merged / published? Is there something blocking these changes from going in?

neferin12 added a commit to educorvi/timeclicker that referenced this pull request Oct 13, 2023
Fix relase by downgrading various semantic relase plugins until pmowrer/semantic-release-monorepo#137 is merged
@junaidrsd
Copy link

Any updates on this?

@bryanjtc
Copy link
Contributor

bryanjtc commented Oct 31, 2023

I think this pr should be simplified. Just convert the project to esm and support new semantic release versions. It should be easier to review with fewer changes.

@jcapogna
Copy link

@bryanjtc It sounds like another hurdle is that the build for this project is broken and needs to be fixed.

@bryanjtc
Copy link
Contributor

bryanjtc commented Nov 1, 2023

@bryanjtc It sounds like another hurdle is that the build for this project is broken and needs to be fixed.

I created a new pr, without the prettier changes to make reviewing them easier. See: #143
It works without errors in a testing pipeline on my fork of this repo: See: https://github.com/bryanjtc/semantic-release-monorepo/actions/runs/6716255451/job/18252207700. It uses a custom patch of semantic-release to allow using an esm extended configuration.

@bryanjtc
Copy link
Contributor

bryanjtc commented Nov 1, 2023

I removed the custom patch and bundled code as solution for this comment: #143 (comment)
Just published my pr as a new package semantic-release-monorepo-esm
v1.0.10 should work without issues.

Copy link

🎉 This issue has been resolved in version 8.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@pmowrer
Copy link
Owner

pmowrer commented Jan 17, 2024

Thanks for doing the work @w4rlock! Ended up merging @bryanjtc's PR because of the smaller diff. Happy to consider any improvements here as follow-on. Lmk

@jcapogna
Copy link

Thanks for getting this out. Huge quality of life improvement :)

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

Successfully merging this pull request may close these issues.

None yet