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

chore: Convert to esm #143

Merged
merged 3 commits into from
Jan 17, 2024
Merged

chore: Convert to esm #143

merged 3 commits into from
Jan 17, 2024

Conversation

bryanjtc
Copy link
Contributor

@bryanjtc bryanjtc commented Nov 1, 2023

Upgrades yarn to v4 and converts projects to esm.
The package still supports cjs by using bundled code.
Drops support for older node and semantic release versions.
Changes jest with vitest. Vitest has better esm support.
Added tsup to bundle the code and output esm and cjs code.
Blocked by: semantic-release/semantic-release#3037

Closes: #138
Closes: #136
Closes: #137
Closes: #140
Closes: #134
Closes: #133
Closes: #128
Closes: #135

@bryanjtc bryanjtc marked this pull request as draft November 1, 2023 05:42
@travi
Copy link

travi commented Nov 1, 2023

Blocked by: semantic-release/semantic-release#3037

this should not be a blocker. see semantic-release/semantic-release#3036 (comment)

@bryanjtc bryanjtc marked this pull request as ready for review November 1, 2023 05:57
@bryanjtc
Copy link
Contributor Author

bryanjtc commented Nov 1, 2023

Blocked by: semantic-release/semantic-release#3037

this should not be a blocker. see semantic-release/semantic-release#3036 (comment)

For testing purposes I ran a config file .releaserc.js .This config file extends an esm file named index.js which is the semantic-release-monorepo config. When semantic release tries to use require on that index.js file it throws this error: semantic-release/semantic-release#3040

The fix proposed in semantic-release/semantic-release#3037 fixes that error. Here is the test pipeline running without errors with a yarn patch of semantic-release using the fix. https://github.com/bryanjtc/semantic-release-monorepo/actions/runs/6716255451/job/18252207700

@travi
Copy link

travi commented Nov 1, 2023

Blocked by: semantic-release/semantic-release#3037

this should not be a blocker. see semantic-release/semantic-release#3036 (comment)

For testing purposes I ran a config file .releaserc.js .This config file extends an esm file named index.js which is the semantic-release-monorepo config. When semantic release tries to use require on that index.js file it throws this error: semantic-release/semantic-release#3040

since you called out that this PR is blocked by the potential update on the semantic-release side, my goal was to highlight that you could instead use an index.cjs instead so that you could configure in a way that works now without being blocked by a change that has not been approved yet. if i were the maintainer of this project, i would not be willing to accept a change that used a patched version of semantic-release. as maintainer of semantic-release, i am not willing to promise a timeline for accepting that change, even though it does seem likely that we could merge it soon. by using the .cjs config, you can decouple this PR from that proposed semantic-release change. if semantic-release does accept the proposed change, you could update to use esm config as a follow up here

The fix proposed in semantic-release/semantic-release#3037 fixes that error. Here is the test pipeline running without errors with a yarn patch of semantic-release using the fix. bryanjtc/semantic-release-monorepo/actions/runs/6716255451/job/18252207700

appreciate the verification that the update works for this scenario, but since i dont maintain this project, be sure to mention things like this on the semantic-release threads since i'm far less likely to spot updates in this repo

@bryanjtc
Copy link
Contributor Author

bryanjtc commented Nov 1, 2023

Blocked by: semantic-release/semantic-release#3037

this should not be a blocker. see semantic-release/semantic-release#3036 (comment)

For testing purposes I ran a config file .releaserc.js .This config file extends an esm file named index.js which is the semantic-release-monorepo config. When semantic release tries to use require on that index.js file it throws this error: semantic-release/semantic-release#3040

since you called out that this PR is blocked by the potential update on the semantic-release side, my goal was to highlight that you could instead use an index.cjs instead so that you could configure in a way that works now without being blocked by a change that has not been approved yet. if i were the maintainer of this project, i would not be willing to accept a change that used a patched version of semantic-release. as maintainer of semantic-release, i am not willing to promise a timeline for accepting that change, even though it does seem likely that we could merge it soon. by using the .cjs config, you can decouple this PR from that proposed semantic-release change. if semantic-release does accept the proposed change, you could update to use esm config as a follow up here

The fix proposed in semantic-release/semantic-release#3037 fixes that error. Here is the test pipeline running without errors with a yarn patch of semantic-release using the fix. bryanjtc/semantic-release-monorepo/actions/runs/6716255451/job/18252207700

appreciate the verification that the update works for this scenario, but since i dont maintain this project, be sure to mention things like this on the semantic-release threads since i'm far less likely to spot updates in this repo

I see your point. I can't change it to a cjs file because imports are not supported in cjs file. I can try using a bundler to convert everything to cjs, including the esm-only dependencies.

@bryanjtc
Copy link
Contributor Author

bryanjtc commented Nov 1, 2023

Just published semantic-release-monorepo-esm 1.0.10 that supports using semantic-release without the patch of semantic-release/semantic-release#3037

@zigang93
Copy link

Just published semantic-release-monorepo-esm 1.0.10 that supports using semantic-release without the patch of semantic-release/semantic-release#3037

it actually not able to release any notes
keep prompt does not provide step "analyzeCommits"

@bryanjtc
Copy link
Contributor Author

Just published semantic-release-monorepo-esm 1.0.10 that supports using semantic-release without the patch of semantic-release/semantic-release#3037

it actually not able to release any notes
keep prompt does not provide step "analyzeCommits"

Can you share the error? Your semantic release config and semantic release package and plugin versions? I will try to reproduce the error to fix it.

@zigang93
Copy link

zigang93 commented Nov 21, 2023

Just published semantic-release-monorepo-esm 1.0.10 that supports using semantic-release without the patch of semantic-release/semantic-release#3037

it actually not able to release any notes
keep prompt does not provide step "analyzeCommits"

Can you share the error? Your semantic release config and semantic release package and plugin versions? I will try to reproduce the error to fix it.

No error happen on github action.. just that no release notes or commit when patch / minor from commit-analyzer

.releaserc.json

{
  "branches": [
    "main",
    { "name": "release", "prerelease": false },
    { "name": "dev", "prerelease": true },
    { "name": "development", "prerelease": true }
  ],
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "angular",
        "releaseRules": [{ "type": "enhancement", "release": "minor" }]
      }
    ],
    [
      "@semantic-release/release-notes-generator",
      {
        "preset": "conventionalcommits",
        "presetConfig": {
          "types": [
            { "type": "feat", "section": "Features", "hidden": false },
            { "type": "fix", "section": "Bug Fixes", "hidden": false },
            {
              "type": "perf",
              "section": "Performance Improvements",
              "hidden": false
            },
            {
              "type": "enhancement",
              "section": "Enhancements",
              "hidden": false
            }
          ]
        }
      }
    ],
    "@semantic-release/changelog",
    [
      "@semantic-release/npm",
      {
        "npmPublish": false
      }
    ],
    [
      "@semantic-release/git",
      {
        "assets": [
          "package.json",
          "pnpm-lock.yaml",
          "pnpm-workspace.yaml",
          "CHANGELOG.md"
        ],
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ],
  ]
}

packages manager: pnpm workspace monorepo
version:
"semantic-release": "^22.0.8"
"@semantic-release/changelog": "^6.0.3"
"@semantic-release/git": "^10.0.1"

@zigang93
Copy link

@bryanjtc I believe in your test github action also facing same problem:
it look fine .. but actually do nothing.. check the "Run semantic-release in dry run" and look for "does not provide step "analyzeCommits" logs
https://github.com/bryanjtc/semantic-release-monorepo/actions/runs/6716255451/job/18252207700

@jtatarik
Copy link

I'm running into similar issue - the tool correctly identifies commits that should trigger a patch release, but nothing happens aferwards.

node: v20.7.0
npx: 10.1.0

package.json:

{
  "name": "XXXXXX",
  "devDependencies": {
    "@semantic-release/changelog": "^6.0.3",
    "@semantic-release/git": "^10.0.1",
    "semantic-release": "^22.0.8",
    "semantic-release-monorepo-esm": "^1.0.10",
    "semantic-release-replace-plugin": "^1.2.7",
    "semantic-release-slack-bot": "^4.0.2"
  }
}

.releaserc.yaml:

---
branches:
  - master
  - feature-branch

plugins:
  - '@semantic-release/commit-analyzer'
  - - semantic-release-replace-plugin
      ...ELIDED...
  - '@semantic-release/release-notes-generator'
  - - '@semantic-release/changelog'
    - changelogTitle: "# Changelog"
  - - '@semantic-release/git'
    - assets:
        - CHANGELOG.md
      message: "chore(release): XXXX-${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
  - '@semantic-release/github'
  - - semantic-release-slack-bot
    - notifyOnSuccess: true
      markdownReleaseNotes: true
      packageName: XXXXX
❯ npx semantic-release -e semantic-release-monorepo-esm --dry-run
[1:55:09 PM] [semantic-release] › ℹ  Running semantic-release version 22.0.8
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/git"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "semantic-release-slack-bot"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "semantic-release-replace-plugin"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/git"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[1:55:10 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[1:55:14 PM] [semantic-release] › ⚠  Run automated release from branch feature-branch on repository [email protected]:XXXX.git in dry-run mode
[1:55:14 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[1:55:14 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[1:55:14 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[1:55:14 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/git"
[1:55:14 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/git"
[1:55:14 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/github"
[1:55:14 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication
[1:55:15 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/github"
[1:55:15 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "semantic-release-slack-bot"
[1:55:15 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "semantic-release-slack-bot"
[1:55:15 PM] [semantic-release] › ℹ  Found git tag XXXX-v0.2.0 associated with version 0.2.0 on branch feature-branch
[1:55:15 PM] [semantic-release] › ℹ  Found 6 commits since last release
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Plugin "semantic-release-replace-plugin" does not provide step "analyzeCommits"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Plugin "@semantic-release/release-notes-generator" does not provide step "analyzeCommits"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Plugin "@semantic-release/changelog" does not provide step "analyzeCommits"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Plugin "@semantic-release/git" does not provide step "analyzeCommits"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Plugin "@semantic-release/github" does not provide step "analyzeCommits"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  No more plugins
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Plugin "semantic-release-slack-bot" does not provide step "analyzeCommits"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  No more plugins
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  No more plugins
[1:55:15 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[1:55:15 PM] [semantic-release] › ℹ  There are no relevant changes, so no new version is released.
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Found 2 commits for package XXXX since last release
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Analyzing commit: fix(XXXX): trigger a release for debugging purposes
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  The release type for the commit is patch
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Analyzing commit: fix(XXXX): trigger a release for debugging purposes
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  The release type for the commit is patch
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Analysis of 2 commits complete: patch release
[1:55:15 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"

I observe the same behavior in CI. The confusing thing is the There are no relevant changes, so no new version is released. log line, which contradicts the later output.

@zigang93
Copy link

@bryanjtc tried latest fix.. still same result

@vis97c
Copy link

vis97c commented Dec 18, 2023

It seems like steps after analyzeCommits are not running

@sinedied
Copy link

@bryanjtc Tried your ESM package, but it's not working. As others reported, nothing happens after analyzeCommits and it says there's no relevant changes while still finding changes after that.

@jtatarik
Copy link

For what it's worth, ended up using https://github.com/Lomray-Software/semantic-release-monorepo, works as expected.

@sinedied
Copy link

Thanks, I'll give it a go!

I would be nice to have a status from the original owner of this repo though, @pmowrer do you still plan to maintain this project? I fully understand that sometimes it's complicated, but if you're not willing to maintain it anymore or need help I'm sure there will be volunteers (me included) to help, so don't hesitate.

@mario-jerkovic
Copy link

@jtatarik @vis97c @vis97c
We've released a monorepo package that's compatible with ESM, and since open source, you're free to customize it as you wish. Cheers! 🍻

NPM package: https://www.npmjs.com/package/@rimac-technology/semantic-release-monorepo
Source code: https://github.com/RimacTechnology/semantic-release-monorepo

@pmowrer
Copy link
Owner

pmowrer commented Jan 17, 2024

@sinedied Yes, planning on sorting this out finally. Sorry everyone for the delays and thanks for the contributions.

pmowrer and others added 2 commits January 17, 2024 11:13
BREAKING CHANGE: Requires semantic-release 20 or above.

Thanks to @bryanjtc for doing all the work to get this done. Much appreciated!

Co-Authored-By: Bryan Thomas <[email protected]>
Co-Authored-By: Tobias Bocanegra <[email protected]>
@pmowrer pmowrer merged commit c9b94c8 into pmowrer:master Jan 17, 2024
2 checks passed
Copy link

🎉 This PR is included in version 8.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bryanjtc
Copy link
Contributor Author

@pmowrer There was still a small issue with analyzeCommits. @pmowrer Did you manage to fix it?

@pmowrer
Copy link
Owner

pmowrer commented Jan 17, 2024

@bryanjtc I saw it mentioned but didn't explicitly address it yet. Would like to better understand what changed to break it.

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