From 85066e20281d606b056a78b712bb81ed1f44af57 Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 6 Aug 2023 17:08:28 +0800 Subject: [PATCH] feat!: bump minimum node version to 18 --- .eslintrc.cjs | 7 ++++--- .github/workflows/ci.yml | 10 ++-------- .github/workflows/publish.yml | 4 ++-- docs/guide/index.md | 2 +- netlify.toml | 2 +- package.json | 2 +- packages/create-vite/README.md | 2 +- packages/create-vite/build.config.ts | 3 ++- packages/create-vite/package.json | 2 +- packages/create-vite/tsconfig.json | 2 +- packages/plugin-legacy/build.config.ts | 3 +++ packages/plugin-legacy/package.json | 2 +- packages/vite/package.json | 2 +- packages/vite/src/node/config.ts | 2 +- packages/vite/tsconfig.base.json | 2 +- playground/tsconfig.json | 2 +- scripts/tsconfig.json | 2 +- vitest.config.e2e.ts | 2 +- vitest.config.ts | 4 +--- 19 files changed, 27 insertions(+), 30 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 6e07fd52419055..6ddcdb6b4ab971 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,6 +1,7 @@ // @ts-check const { builtinModules } = require('node:module') const { defineConfig } = require('eslint-define-config') +const pkg = require('./package.json') module.exports = defineConfig({ root: true, @@ -16,7 +17,7 @@ module.exports = defineConfig({ parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module', - ecmaVersion: 2021, + ecmaVersion: 2022, }, rules: { eqeqeq: ['warn', 'always', { null: 'never' }], @@ -173,13 +174,13 @@ module.exports = defineConfig({ 'n/no-unsupported-features/es-builtins': [ 'error', { - version: '^14.18.0 || >=16.0.0', + version: pkg.engines.node, }, ], 'n/no-unsupported-features/node-builtins': [ 'error', { - version: '^14.18.0 || >=16.0.0', + version: pkg.engines.node, }, ], '@typescript-eslint/explicit-module-boundary-types': 'off', diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e46f8950fdc12..b0af67e3813103 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node_version: [14, 16, 18, 20] + node_version: [18, 20] include: # Active LTS + other OS - os: macos-latest @@ -67,14 +67,8 @@ jobs: packages/create-vite/template** **.md - - name: Install pnpm (node 14, pnpm 7) - if: steps.changed-files.outputs.only_changed != 'true' && matrix.node_version == 14 - uses: pnpm/action-setup@v2.4.0 - with: - version: 7 - - name: Install pnpm - if: steps.changed-files.outputs.only_changed != 'true' && matrix.node_version != 14 + if: steps.changed-files.outputs.only_changed != 'true' uses: pnpm/action-setup@v2.4.0 - name: Set node version to ${{ matrix.node_version }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ed3cd92dd84f33..3102c7176bf9f8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,10 +23,10 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v2.4.0 - - name: Set node version to 16.x + - name: Set node version to 18 uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 18 registry-url: https://registry.npmjs.org/ cache: "pnpm" diff --git a/docs/guide/index.md b/docs/guide/index.md index ebe76458c21984..7531c1ce5b30bf 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -42,7 +42,7 @@ The supported template presets are: ## Scaffolding Your First Vite Project ::: tip Compatibility Note -Vite requires [Node.js](https://nodejs.org/en/) version 14.18+, 16+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it. +Vite requires [Node.js](https://nodejs.org/en/) version 18+. 20+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it. ::: With NPM: diff --git a/netlify.toml b/netlify.toml index 961d936bd686e5..d78254570def67 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,5 +1,5 @@ [build.environment] - NODE_VERSION = "16" + NODE_VERSION = "18" # don't need playwright for docs build PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1" [build] diff --git a/package.json b/package.json index f755862b017858..2e76703534dfee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^18.0.0 || >=20.0.0" }, "homepage": "https://vitejs.dev/", "repository": { diff --git a/packages/create-vite/README.md b/packages/create-vite/README.md index 8776ab3c3aeb3c..ea05ce4009beaf 100644 --- a/packages/create-vite/README.md +++ b/packages/create-vite/README.md @@ -3,7 +3,7 @@ ## Scaffolding Your First Vite Project > **Compatibility Note:** -> Vite requires [Node.js](https://nodejs.org/en/) version 14.18+, 16+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it. +> Vite requires [Node.js](https://nodejs.org/en/) version 18+, 20+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it. With NPM: diff --git a/packages/create-vite/build.config.ts b/packages/create-vite/build.config.ts index 435c39bc937a6a..71d1ba88717d6d 100644 --- a/packages/create-vite/build.config.ts +++ b/packages/create-vite/build.config.ts @@ -11,11 +11,12 @@ export default defineBuildConfig({ rollup: { inlineDependencies: true, esbuild: { + target: 'node18', minify: true, }, }, alias: { - // we can always use non-transpiled code since we support 14.18.0+ + // we can always use non-transpiled code since we support node 18+ prompts: 'prompts/lib/index.js', }, hooks: { diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 94134bdd378846..8ee1ddf9224f30 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -20,7 +20,7 @@ "prepublishOnly": "npm run build" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^18.0.0 || >=20.0.0" }, "repository": { "type": "git", diff --git a/packages/create-vite/tsconfig.json b/packages/create-vite/tsconfig.json index 65fffe74592b9b..9fc23ebe675e0f 100644 --- a/packages/create-vite/tsconfig.json +++ b/packages/create-vite/tsconfig.json @@ -2,7 +2,7 @@ "include": ["build.config.ts", "src", "__tests__"], "compilerOptions": { "outDir": "dist", - "target": "ES2020", + "target": "ES2022", "module": "ES2020", "moduleResolution": "bundler", "strict": true, diff --git a/packages/plugin-legacy/build.config.ts b/packages/plugin-legacy/build.config.ts index db325ecfa3b0a8..f7e0fdb0bc049f 100644 --- a/packages/plugin-legacy/build.config.ts +++ b/packages/plugin-legacy/build.config.ts @@ -7,5 +7,8 @@ export default defineBuildConfig({ rollup: { emitCJS: true, inlineDependencies: true, + esbuild: { + target: 'node18', + }, }, }) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index ee78c70817f109..801dcb557e968e 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -29,7 +29,7 @@ "prepublishOnly": "npm run build" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^18.0.0 || >=20.0.0" }, "repository": { "type": "git", diff --git a/packages/vite/package.json b/packages/vite/package.json index 162fb450541d1c..cfe0172e0c6df1 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -38,7 +38,7 @@ "types" ], "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^18.0.0 || >=20.0.0" }, "repository": { "type": "git", diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index f73ae2ae703e1c..916af948368d9b 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -1017,7 +1017,7 @@ async function bundleConfigFile( entryPoints: [fileName], outfile: 'out.js', write: false, - target: ['node14.18', 'node16'], + target: ['node18'], platform: 'node', bundle: true, format: isESM ? 'esm' : 'cjs', diff --git a/packages/vite/tsconfig.base.json b/packages/vite/tsconfig.base.json index 37eb865185662d..04df5b8dd6f5d7 100644 --- a/packages/vite/tsconfig.base.json +++ b/packages/vite/tsconfig.base.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2020", + "target": "ES2022", "module": "ESNext", "moduleResolution": "node", "strict": true, diff --git a/playground/tsconfig.json b/playground/tsconfig.json index ff409529cce345..e45775a61ff855 100644 --- a/playground/tsconfig.json +++ b/playground/tsconfig.json @@ -3,7 +3,7 @@ "exclude": ["**/dist/**"], "compilerOptions": { "checkJs": true, - "target": "ES2020", + "target": "ES2022", "module": "ESNext", "outDir": "dist", "baseUrl": ".", diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 359dd1aeafb2b3..224db1f6787c05 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "include": ["."], "compilerOptions": { - "module": "ES2020", + "module": "ES2022", "target": "ES2020", "moduleResolution": "Node", "strict": true, diff --git a/vitest.config.e2e.ts b/vitest.config.e2e.ts index 471d7859968710..fa0d76f1cd508d 100644 --- a/vitest.config.e2e.ts +++ b/vitest.config.e2e.ts @@ -26,6 +26,6 @@ export default defineConfig({ }, }, esbuild: { - target: 'node14', + target: 'node18', }, }) diff --git a/vitest.config.ts b/vitest.config.ts index 70340ed38cfe7b..98aed39da4f636 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -10,10 +10,8 @@ export default defineConfig({ './playground-temp/**/*.*', ], testTimeout: 20000, - // node14 segfaults often with threads - threads: !process.versions.node.startsWith('14'), }, esbuild: { - target: 'node14', + target: 'node18', }, })