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

@gitbeaker/cli does not work on Node 22 #3591

Closed
2 tasks done
kashz opened this issue May 19, 2024 · 4 comments · Fixed by #3592
Closed
2 tasks done

@gitbeaker/cli does not work on Node 22 #3591

kashz opened this issue May 19, 2024 · 4 comments · Fixed by #3592
Labels
released This issue/pull request has been released. type:hot fix Changes fix a critical bug

Comments

@kashz
Copy link
Contributor

kashz commented May 19, 2024

Description

  • Node.js version: 22.2.0
  • Gitbeaker version: 40.0.3
  • Gitbeaker release (cli, rest, core, requester-utils): core, cli
$ gitbeaker --version
file:///Users/xxx/.asdf/installs/nodejs/22.2.0/lib/node_modules/@gitbeaker/cli/dist/index.mjs:5
import API_MAP from '@gitbeaker/core/map.json' assert { type: 'json' };
                                               ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:163:18)
    at callTranslator (node:internal/modules/esm/loader:430:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:436:30)
    at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)

Node.js v22.2.0

I've encountered an issue where @gitbeaker/cli does not work with Node 22.
This is because the assert keyword has been removed in Node 22.

nodejs/node#52104

Replacing it with the with keyword should resolve the issue, but the with keyword does not work on Node versions less than 18.20.0, which may affect the supported Node versions.

Checklist

  • I have checked that this is not a duplicate issue.
  • I have read the documentation.
@jdalrymple jdalrymple added the type:hot fix Changes fix a critical bug label May 19, 2024
@jdalrymple
Copy link
Owner

Shouldnt be a problem since the libs lowest version is 18!

@jdalrymple
Copy link
Owner

🚀 Issue was released in 40.1.0 🚀

@jdalrymple jdalrymple added the released This issue/pull request has been released. label Jul 8, 2024
@kashz
Copy link
Contributor Author

kashz commented Jul 15, 2024

@jdalrymple
Thank you for your work on this issue. However, it seems that the issue has not been fixed yet in version 40.1.2.
The with keyword is being converted to assert during the build process.

dist/index.mjs:5
https://www.npmjs.com/package/@gitbeaker/cli/v/40.1.2?activeTab=code

This happens because when tsup is used with the --treeshake option, it uses rollup for bundling instead of esbuild.

https://github.com/jdalrymple/gitbeaker/blob/40.1.2/packages/cli/package.json#L34
https://tsup.egoist.dev/#tree-shaking

By default, rollup converts import attributes to assert.

https://rollupjs.org/configuration-options/#output-importattributeskey

Since esbuild performs tree shaking by default, I think using esbuild might be a better solution.
What are your thoughts on this?

@jdalrymple
Copy link
Owner

I really thought tsup used esbuild under the hood. Im open to using instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released. type:hot fix Changes fix a critical bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants