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

fix(cli): add globalThis.crypto polyfill for Node.js 18 #771

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Mar 6, 2025

(same as nitrojs/nitro#3167)

As Node.js 18 is getting EOL, more ecosystem packages might depend on globalThis.crypto which in unavailable in 18 and one of the biggest differences between 18/20.

This makes sure nuxt build/dev will be compatible in this situation.

@pi0 pi0 requested a review from danielroe as a code owner March 6, 2025 16:28
Copy link

pkg-pr-new bot commented Mar 6, 2025

Open in Stackblitz

npm i https://pkg.pr.new/create-nuxt@771
npm i https://pkg.pr.new/@nuxt/cli@771
npm i https://pkg.pr.new/nuxi@771

commit: 6ad8b8f

Copy link
Contributor

github-actions bot commented Mar 6, 2025

Bundle Stats — create-nuxt size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
50 5.71 MB → 5.71 MB (+84 B) +0.00%
Changeset
File Δ Size
home/runner/work/cli/cli/packages/nuxi/src/main.ts 📈 +62 B (+5.25%) 1.15 kB → 1.21 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
shared/create-nuxt.DvlRjKsj.mjs 0 B → 2.02 MB (+2.02 MB) -
shared/create-nuxt.DBV5Tar6.mjs 0 B → 813.58 kB (+813.58 kB) -
shared/create-nuxt.kxrn9bsF.mjs 0 B → 124.17 kB (+124.17 kB) -
shared/create-nuxt.Bslbi8ER.mjs 0 B → 108.13 kB (+108.13 kB) -
shared/create-nuxt.BZtr03Vg.mjs 0 B → 14.64 kB (+14.64 kB) -
shared/create-nuxt.BFYt0oM0.mjs 0 B → 4.07 kB (+4.07 kB) -
shared/create-nuxt.BctcO1-M.mjs 0 B → 3.9 kB (+3.9 kB) -
shared/create-nuxt.BejaPFkV.mjs 0 B → 836 B (+836 B) -
shared/create-nuxt.B_pu9pI9.mjs 0 B → 804 B (+804 B) -
shared/create-nuxt.BRsWZ2IN.mjs 0 B → 294 B (+294 B) -

Removed

Asset File Size % Changed
shared/create-nuxt.DsZZWyl0.mjs 2.02 MB → 0 B (-2.02 MB) -100%
shared/create-nuxt.Bkx3DtBW.mjs 813.52 kB → 0 B (-813.52 kB) -100%
shared/create-nuxt.B0RhWsA5.mjs 124.17 kB → 0 B (-124.17 kB) -100%
shared/create-nuxt.CdL-wLDR.mjs 108.13 kB → 0 B (-108.13 kB) -100%
shared/create-nuxt.D726QGe3.mjs 14.64 kB → 0 B (-14.64 kB) -100%
shared/create-nuxt.iyGHE4Z0.mjs 4.07 kB → 0 B (-4.07 kB) -100%
shared/create-nuxt.CS-g04NK.mjs 3.9 kB → 0 B (-3.9 kB) -100%
shared/create-nuxt.DZTeD13_.mjs 836 B → 0 B (-836 B) -100%
shared/create-nuxt.BhqolJ_P.mjs 804 B → 0 B (-804 B) -100%
shared/create-nuxt.C73dJnGP.mjs 294 B → 0 B (-294 B) -100%

Bigger

Asset File Size % Changed
index.mjs 1.05 kB → 1.07 kB (+22 B) +2.05%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
chunks/multipart-parser.mjs 5.11 kB 0%
chunks/add.mjs 6.83 kB 0%
chunks/analyze.mjs 3.18 kB 0%
chunks/build.mjs 1.97 kB 0%
chunks/cleanup.mjs 471 B 0%
chunks/dev-child.mjs 1.96 kB 0%
chunks/dev.mjs 7.48 kB 0%
chunks/devtools.mjs 764 B 0%
chunks/generate.mjs 388 B 0%
chunks/info.mjs 4.39 kB 0%
chunks/index.mjs 274 B 0%
chunks/prepare.mjs 984 B 0%
chunks/preview.mjs 3.22 kB 0%
chunks/test.mjs 1.16 kB 0%
chunks/typecheck.mjs 1.74 kB 0%
chunks/upgrade.mjs 6.25 kB 0%
chunks/prompt.mjs 42.92 kB 0%
chunks/satisfies.mjs 116 B 0%
chunks/kit.mjs 1.34 kB 0%
chunks/index2.mjs 1.17 MB 0%
chunks/dev2.mjs 70 kB 0%
chunks/index3.mjs 17.14 kB 0%
chunks/index4.mjs 71.98 kB 0%
chunks/add2.mjs 12.21 kB 0%
chunks/search.mjs 45.83 kB 0%
chunks/xdg-open.mjs 25.32 kB 0%
chunks/node.mjs 134.23 kB 0%
chunks/index5.mjs 1.23 kB 0%
chunks/index6.mjs 6.25 kB 0%
chunks/index7.mjs 50.51 kB 0%
chunks/index8.mjs 5.85 kB 0%
chunks/index9.mjs 885.9 kB 0%
chunks/multipart-parser2.mjs 4.58 kB 0%
shared/create-nuxt.CWMKGdSL.mjs 18.95 kB 0%
shared/create-nuxt.BSm0_9Hr.mjs 107 B 0%
shared/create-nuxt.jjur9XJH.mjs 43.55 kB 0%
shared/create-nuxt.BjhZEm2-.mjs 1.75 kB 0%
shared/create-nuxt.D4vggcPe.mjs 5.7 kB 0%
shared/create-nuxt.DnK9Crop.mjs 26.94 kB 0%

Copy link
Contributor

github-actions bot commented Mar 6, 2025

Bundle Stats — nuxt-cli size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
30 81.12 kB → 81.18 kB (+62 B) +0.07%
Changeset
File Δ Size
home/runner/work/cli/cli/packages/nuxi/src/main.ts 📈 +62 B (+5.56%) 1.09 kB → 1.15 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
shared/cli.DpG3sfzG.mjs 0 B → 1.72 kB (+1.72 kB) -

Removed

Asset File Size % Changed
shared/cli.BxfHsa2l.mjs 1.66 kB → 0 B (-1.66 kB) -100%

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
index.mjs 224 B 0%
chunks/add.mjs 6.83 kB 0%
chunks/analyze.mjs 3.18 kB 0%
chunks/build.mjs 1.97 kB 0%
chunks/cleanup.mjs 471 B 0%
chunks/dev-child.mjs 1.97 kB 0%
chunks/dev.mjs 7.43 kB 0%
chunks/devtools.mjs 763 B 0%
chunks/generate.mjs 388 B 0%
chunks/info.mjs 4.39 kB 0%
chunks/init.mjs 6.36 kB 0%
chunks/index.mjs 274 B 0%
chunks/prepare.mjs 984 B 0%
chunks/preview.mjs 3.22 kB 0%
chunks/test.mjs 1.16 kB 0%
chunks/typecheck.mjs 1.74 kB 0%
chunks/upgrade.mjs 6.25 kB 0%
chunks/dev2.mjs 8.16 kB 0%
chunks/add2.mjs 10.3 kB 0%
chunks/search.mjs 2.94 kB 0%
shared/cli.CoF9h-QJ.mjs 5.5 kB 0%
shared/cli.DxJ-hGZS.mjs 804 B 0%
shared/cli.DWIYPwr_.mjs 294 B 0%
shared/cli.DFn4s9n_.mjs 1.23 kB 0%
shared/cli.BSm0_9Hr.mjs 107 B 0%
shared/cli.t8II6e4p.mjs 836 B 0%
shared/cli.DlcAx0De.mjs 1.04 kB 0%
shared/cli.xqYKEjVw.mjs 78 B 0%
shared/cli.C935N1ss.mjs 687 B 0%

Copy link
Contributor

github-actions bot commented Mar 6, 2025

Bundle Stats — nuxi size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
54 5.29 MB → 5.29 MB (+84 B) +0.00%
Changeset
File Δ Size
src/main.ts 📈 +62 B (+5.47%) 1.11 kB → 1.17 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
shared/nuxi.Bn2Umjh5.mjs 0 B → 76.15 kB (+76.15 kB) -
shared/nuxi.D89N5lNo.mjs 0 B → 4.07 kB (+4.07 kB) -
shared/nuxi.DxjG1CPh.mjs 0 B → 2.57 kB (+2.57 kB) -
shared/nuxi.BgxCfP1E.mjs 0 B → 836 B (+836 B) -
shared/nuxi.Dd35yPme.mjs 0 B → 804 B (+804 B) -
shared/nuxi.LTAZ5I7Y.mjs 0 B → 294 B (+294 B) -

Removed

Asset File Size % Changed
shared/nuxi.o-rKvXAJ.mjs 76.09 kB → 0 B (-76.09 kB) -100%
shared/nuxi.-rRxjSnQ.mjs 4.07 kB → 0 B (-4.07 kB) -100%
shared/nuxi.zDuRO7fy.mjs 2.57 kB → 0 B (-2.57 kB) -100%
shared/nuxi.zTGCm4pM.mjs 836 B → 0 B (-836 B) -100%
shared/nuxi.CI7m26dn.mjs 804 B → 0 B (-804 B) -100%
shared/nuxi.CP0eN2ju.mjs 294 B → 0 B (-294 B) -100%

Bigger

Asset File Size % Changed
index.mjs 188 B → 210 B (+22 B) +11.70%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
chunks/prompt.mjs 42.92 kB 0%
chunks/add.mjs 6.83 kB 0%
chunks/analyze.mjs 3.18 kB 0%
chunks/build.mjs 1.97 kB 0%
chunks/cleanup.mjs 471 B 0%
chunks/dev-child.mjs 1.96 kB 0%
chunks/dev.mjs 7.48 kB 0%
chunks/devtools.mjs 764 B 0%
chunks/generate.mjs 388 B 0%
chunks/info.mjs 4.39 kB 0%
chunks/init.mjs 662.47 kB 0%
chunks/index.mjs 274 B 0%
chunks/prepare.mjs 984 B 0%
chunks/preview.mjs 3.22 kB 0%
chunks/test.mjs 1.16 kB 0%
chunks/typecheck.mjs 1.74 kB 0%
chunks/upgrade.mjs 6.25 kB 0%
chunks/satisfies.mjs 116 B 0%
chunks/main.mjs 15.3 kB 0%
chunks/index2.mjs 915.2 kB 0%
chunks/dev2.mjs 70 kB 0%
chunks/index3.mjs 17.14 kB 0%
chunks/index4.mjs 71.98 kB 0%
chunks/multipart-parser.mjs 5.11 kB 0%
chunks/add2.mjs 12.21 kB 0%
chunks/search.mjs 45.83 kB 0%
chunks/xdg-open.mjs 25.32 kB 0%
chunks/node.mjs 134.23 kB 0%
chunks/index5.mjs 1.23 kB 0%
chunks/index6.mjs 5.85 kB 0%
chunks/index7.mjs 885.9 kB 0%
chunks/multipart-parser2.mjs 4.58 kB 0%
shared/nuxi.DqkIr2yV.mjs 18.95 kB 0%
shared/nuxi.D2_bzAv0.mjs 1.54 kB 0%
shared/nuxi.BSm0_9Hr.mjs 107 B 0%
shared/nuxi._8J0PkaN.mjs 1.34 kB 0%
shared/nuxi.CoaHqGOR.mjs 14.64 kB 0%
shared/nuxi.BcEzdr5W.mjs 10.03 kB 0%
shared/nuxi.BjycWew7.mjs 2.02 MB 0%
shared/nuxi.E-ZsRS8r.mjs 943 B 0%
shared/nuxi.BjhZEm2-.mjs 1.75 kB 0%
shared/nuxi.CHtkLRvK.mjs 124.17 kB 0%
shared/nuxi.Kph9bHCN.mjs 26.94 kB 0%
shared/nuxi.D4vggcPe.mjs 5.7 kB 0%
shared/nuxi.JlPZHmu9.mjs 53.93 kB 0%
shared/nuxi.Do0aYBCO.mjs 5.46 kB 0%
shared/nuxi.jjur9XJH.mjs 43.55 kB 0%

@danielroe danielroe merged commit 4948828 into main Mar 6, 2025
11 checks passed
@danielroe danielroe deleted the fix/node-18-polyfill branch March 6, 2025 16:39
@github-actions github-actions bot mentioned this pull request Mar 6, 2025
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

Successfully merging this pull request may close these issues.

2 participants