diff --git a/.github/issue-workflow-dark.png b/.github/issue-workflow-dark.png new file mode 100644 index 00000000000000..fe32a6dc507b0c Binary files /dev/null and b/.github/issue-workflow-dark.png differ diff --git a/.github/pr-workflow-dark.png b/.github/pr-workflow-dark.png new file mode 100644 index 00000000000000..35a53f29637201 Binary files /dev/null and b/.github/pr-workflow-dark.png differ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71a4aa09841ebe..65fb07f88fad9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -180,11 +180,17 @@ You can set the `DEBUG` environment variable to turn on debugging logs. E.g. `DE ### Issue Triaging Workflow -![issue-workflow](./.github/issue-workflow.png) + + + + ### Pull Request Review Workflow -![issue-workflow](./.github/pr-workflow.png) + + + + ## Notes on Dependencies diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 7baf0d9e6714bc..3f7762f2cdd2c4 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -57,7 +57,8 @@ export default defineConfig({ text: 'English', items: [ { text: '简体中文', link: 'https://cn.vitejs.dev' }, - { text: '日本語', link: 'https://ja.vitejs.dev' } + { text: '日本語', link: 'https://ja.vitejs.dev' }, + { text: 'Español', link: 'https://es.vitejs.dev' } ] }, diff --git a/docs/config/build-options.md b/docs/config/build-options.md index afe60c86052b36..e4882e111c51ee 100644 --- a/docs/config/build-options.md +++ b/docs/config/build-options.md @@ -145,7 +145,7 @@ Produce SSR-oriented build. The value can be a string to directly specify the SS Set to `false` to disable minification, or specify the minifier to use. The default is [esbuild](https://github.com/evanw/esbuild) which is 20 ~ 40x faster than terser and only 1 ~ 2% worse compression. [Benchmarks](https://github.com/privatenumber/minification-benchmarks) -Note the `build.minify` option is not available when using the `'es'` format in lib mode. +Note the `build.minify` option does not minify whitespaces when using the `'es'` format in lib mode, as it removes pure annotations and break tree-shaking. Terser must be installed when it is set to `'terser'`. diff --git a/docs/config/preview-options.md b/docs/config/preview-options.md index 7f99c916bab1f0..10ec82f38e3848 100644 --- a/docs/config/preview-options.md +++ b/docs/config/preview-options.md @@ -42,7 +42,7 @@ export default defineConfig({ - **Type:** `boolean` - **Default:** [`server.strictPort`](./server-options#server-strictport) -Set to `true` to exit if port is already in use, instead of automatically try the next available port. +Set to `true` to exit if port is already in use, instead of automatically trying the next available port. ## preview.https diff --git a/docs/config/server-options.md b/docs/config/server-options.md index b77c69be7d2ee0..6a5ae5ebab3aa4 100644 --- a/docs/config/server-options.md +++ b/docs/config/server-options.md @@ -45,7 +45,7 @@ Specify server port. Note if the port is already being used, Vite will automatic - **Type:** `boolean` -Set to `true` to exit if port is already in use, instead of automatically try the next available port. +Set to `true` to exit if port is already in use, instead of automatically trying the next available port. ## server.https diff --git a/docs/config/shared-options.md b/docs/config/shared-options.md index 2ae42cb88500c4..774c35df42a5a5 100644 --- a/docs/config/shared-options.md +++ b/docs/config/shared-options.md @@ -280,6 +280,8 @@ export default defineConfig({ }) ``` +When [`build.minify`](./build-options.md#build-minify) is `true`, you can configure to only minify [certain aspects](https://esbuild.github.io/api/#minify) of the code by setting either of `esbuild.minifyIdentifiers`, `esbuild.minifySyntax`, and `esbuild.minifyWhitespace` to `true`. Note the `esbuild.minify` option can't be used to override `build.minify`. + Set to `false` to disable esbuild transforms. ## assetsInclude diff --git a/docs/guide/index.md b/docs/guide/index.md index 3ced5c248c4b78..f0f327c22988a2 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -74,7 +74,7 @@ npm create vite@latest my-vue-app -- --template vue yarn create vite my-vue-app --template vue # pnpm -pnpm create vite my-vue-app -- --template vue +pnpm create vite my-vue-app --template vue ``` See [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite) for more details on each supported template: `vanilla`, `vanilla-ts`, `vue`, `vue-ts`, `react`, `react-ts`, `preact`, `preact-ts`, `lit`, `lit-ts`, `svelte`, `svelte-ts`. diff --git a/netlify.toml b/netlify.toml index 5ff3c0d6323342..f618d808000f61 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,4 +3,5 @@ NPM_FLAGS = "--version" # prevent Netlify npm install [build] publish = "docs/.vitepress/dist" - command = "npx pnpm i --store=node_modules/.pnpm-store --frozen-lockfile && npm run ci-docs" \ No newline at end of file + command = "npx pnpm i --store=node_modules/.pnpm-store --frozen-lockfile && npm run ci-docs" + ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF docs package.json pnpm-lock.yaml netlify.toml" \ No newline at end of file diff --git a/package.json b/package.json index 83092bdf3d11b8..807bafba200cdc 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,14 @@ ], "scripts": { "preinstall": "npx only-allow pnpm", + "postinstall": "simple-git-hooks", "format": "prettier --write --cache .", "lint": "eslint --cache packages/*/{src,types,__tests__}/** playground/**/__tests__/**/*.ts scripts/**", "typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit", "test": "run-s test-unit test-serve test-build", "test-serve": "vitest run -c vitest.config.e2e.ts", "test-build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts", + "test-build-legacy-cjs": "cross-env VITE_TEST_LEGACY_CJS_PLUGIN=1 pnpm test-build", "test-unit": "vitest run", "test-docs": "pnpm run docs-build", "debug-serve": "cross-env VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts", @@ -29,8 +31,8 @@ "docs-serve": "vitepress serve docs", "build": "pnpm -r --filter=./packages/* run build", "dev": "pnpm -r --parallel --filter=./packages/* run dev", - "release": "esno scripts/release.ts", - "ci-publish": "esno scripts/publishCI.ts", + "release": "tsx scripts/release.ts", + "ci-publish": "tsx scripts/publishCI.ts", "ci-docs": "run-s build docs-build" }, "devDependencies": { @@ -66,7 +68,6 @@ "eslint-define-config": "^1.5.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-node": "^11.1.0", - "esno": "^0.16.3", "execa": "^6.1.0", "fs-extra": "^10.1.0", "kill-port": "^1.6.1", @@ -85,6 +86,7 @@ "simple-git-hooks": "^2.8.0", "sirv": "^2.0.2", "tslib": "^2.4.0", + "tsx": "^3.6.0", "typescript": "^4.6.4", "unbuild": "^0.7.4", "vite": "workspace:*", @@ -94,7 +96,7 @@ }, "simple-git-hooks": { "pre-commit": "pnpm exec lint-staged --concurrent false", - "commit-msg": "pnpm exec esno scripts/verifyCommit.ts $1" + "commit-msg": "pnpm exec tsx scripts/verifyCommit.ts $1" }, "lint-staged": { "*": [ diff --git a/packages/create-vite/README.md b/packages/create-vite/README.md index dd00043cac4b09..519268a4d79da2 100644 --- a/packages/create-vite/README.md +++ b/packages/create-vite/README.md @@ -38,7 +38,7 @@ npm create vite@latest my-vue-app -- --template vue yarn create vite my-vue-app --template vue # pnpm -pnpm create vite my-vue-app -- --template vue +pnpm create vite my-vue-app --template vue ``` Currently supported template presets include: diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 89c958cec08b01..01267c9c56ca50 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -19,7 +19,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "esno ../../scripts/patchCJS.ts", + "patch-cjs": "tsx ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 3ada42a44c0bcb..dcc4c57da10aea 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -23,7 +23,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "esno ../../scripts/patchCJS.ts", + "patch-cjs": "tsx ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 3e7ef4e9c4e384..9aa3f94dc5b2f7 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -276,7 +276,10 @@ export default function viteReact(opts: Options = {}): PluginOption[] { !(isProjectFile && babelOptions.babelrc) if (shouldSkip) { - return // Avoid parsing if no plugins exist. + // Avoid parsing if no plugins exist. + return { + code + } } const parserPlugins: typeof babelOptions.parserOpts.plugins = [ diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 987b76debad33e..5d14a2dcd56cc0 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -19,7 +19,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "esno ../../scripts/patchCJS.ts", + "patch-cjs": "tsx ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index 0c69c720094c3b..84cc1983a2c9a5 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -19,7 +19,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "esno ../../scripts/patchCJS.ts", + "patch-cjs": "tsx ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/plugin-vue/src/helper.ts b/packages/plugin-vue/src/helper.ts index 64e27560849dee..45068a78bc3fdf 100644 --- a/packages/plugin-vue/src/helper.ts +++ b/packages/plugin-vue/src/helper.ts @@ -1,4 +1,4 @@ -export const EXPORT_HELPER_ID = 'plugin-vue:export-helper' +export const EXPORT_HELPER_ID = '\0plugin-vue:export-helper' export const helperCode = ` export default (sfc, props) => { diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index d4fd9da24f9f09..4a0b6c8fc6f623 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,17 @@ +## 3.0.0-beta.2 (2022-06-24) + +* feat: enable tree-shaking for lib es (#8737) ([5dc0f72](https://github.com/vitejs/vite/commit/5dc0f72)), closes [#8737](https://github.com/vitejs/vite/issues/8737) +* feat: supports cts and mts config (#8729) ([c2b09db](https://github.com/vitejs/vite/commit/c2b09db)), closes [#8729](https://github.com/vitejs/vite/issues/8729) +* fix: avoid type mismatch with Rollup (fix #7843) (#8701) ([87e51f7](https://github.com/vitejs/vite/commit/87e51f7)), closes [#7843](https://github.com/vitejs/vite/issues/7843) [#8701](https://github.com/vitejs/vite/issues/8701) +* fix: optimizeDeps.entries transformRequest url (fix #8719) (#8748) ([9208c3b](https://github.com/vitejs/vite/commit/9208c3b)), closes [#8719](https://github.com/vitejs/vite/issues/8719) [#8748](https://github.com/vitejs/vite/issues/8748) +* fix(hmr): __HMR_PORT__ should not be `'undefined'` (#8761) ([3271266](https://github.com/vitejs/vite/commit/3271266)), closes [#8761](https://github.com/vitejs/vite/issues/8761) +* perf(lib): improve helper inject regex (#8741) ([19fc7e5](https://github.com/vitejs/vite/commit/19fc7e5)), closes [#8741](https://github.com/vitejs/vite/issues/8741) +* refactor: remove unnecessary condition (#8742) ([2ae269e](https://github.com/vitejs/vite/commit/2ae269e)), closes [#8742](https://github.com/vitejs/vite/issues/8742) +* docs: fix alpha changelog links (#8736) ([31348b5](https://github.com/vitejs/vite/commit/31348b5)), closes [#8736](https://github.com/vitejs/vite/issues/8736) +* chore: v3 beta release notes (#8718) ([7e899d0](https://github.com/vitejs/vite/commit/7e899d0)), closes [#8718](https://github.com/vitejs/vite/issues/8718) + + + ## 3.0.0-beta.1 (2022-06-22) ### Main Changes @@ -166,81 +180,81 @@ #### [3.0.0-beta.0](https://github.com/vitejs/vite/compare/v2.9.12...v3.0.0-beta.0) (2022-06-21) -See [3.0.0-beta.0 changelog](https://github.com/vitejs/vite/blob/3.0.0-beta.0/packages/vite/CHANGELOG.md) +See [3.0.0-beta.0 changelog](https://github.com/vitejs/vite/blob/v3.0.0-beta.0/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.14](https://github.com/vitejs/vite/compare/v3.0.0-alpha.13...v3.0.0-alpha.14) (2022-06-20) -See [3.0.0-alpha.14 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.14/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.14 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.14/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.13](https://github.com/vitejs/vite/compare/v3.0.0-alpha.12...v3.0.0-alpha.13) (2022-06-19) -See [3.0.0-alpha.13 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.13/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.13 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.13/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.12](https://github.com/vitejs/vite/compare/v3.0.0-alpha.11...v3.0.0-alpha.12) (2022-06-16) -See [3.0.0-alpha.12 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.12/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.12 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.12/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.11](https://github.com/vitejs/vite/compare/v3.0.0-alpha.10...v3.0.0-alpha.11) (2022-06-14) -See [3.0.0-alpha.11 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.11/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.11 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.11/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.10](https://github.com/vitejs/vite/compare/v3.0.0-alpha.9...v3.0.0-alpha.10) (2022-06-10) -See [3.0.0-alpha.10 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.10/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.10 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.10/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.9](https://github.com/vitejs/vite/compare/v3.0.0-alpha.8...v3.0.0-alpha.9) (2022-06-01) -See [3.0.0-alpha.9 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.9/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.9 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.9/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.8](https://github.com/vitejs/vite/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2022-05-31) -See [3.0.0-alpha.8 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.8/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.8 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.8/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.7](https://github.com/vitejs/vite/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2022-05-27) -See [3.0.0-alpha.7 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.7/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.7 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.7/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.6](https://github.com/vitejs/vite/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2022-05-27) -See [3.0.0-alpha.6 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.6/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.6 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.6/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.5](https://github.com/vitejs/vite/compare/v3.0.0-alpha.4...v3.0.0-alpha.5) (2022-05-26) -See [3.0.0-alpha.5 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.5/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.5 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.5/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.4](https://github.com/vitejs/vite/compare/v3.0.0-alpha.3...v3.0.0-alpha.4) (2022-05-25) -See [3.0.0-alpha.4 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.4/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.4 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.4/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.3](https://github.com/vitejs/vite/compare/v3.0.0-alpha.2...v3.0.0-alpha.3) (2022-05-25) -See [3.0.0-alpha.3 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.3/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.3 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.3/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.2](https://github.com/vitejs/vite/compare/v3.0.0-alpha.1...v3.0.0-alpha.2) (2022-05-23) -See [3.0.0-alpha.2 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.2/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.2 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.2/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.1](https://github.com/vitejs/vite/compare/v3.0.0-alpha.0...v3.0.0-alpha.1) (2022-05-18) -See [3.0.0-alpha.1 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.1/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.1 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.1/packages/vite/CHANGELOG.md) #### [3.0.0-alpha.0](https://github.com/vitejs/vite/compare/v2.9.12...v3.0.0-alpha.0) (2022-05-13) -See [3.0.0-alpha.0 changelog](https://github.com/vitejs/vite/blob/3.0.0-alpha.0/packages/vite/CHANGELOG.md) +See [3.0.0-alpha.0 changelog](https://github.com/vitejs/vite/blob/v3.0.0-alpha.0/packages/vite/CHANGELOG.md) diff --git a/packages/vite/package.json b/packages/vite/package.json index f2966d3378aef2..eaef97234ad03e 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "3.0.0-beta.1", + "version": "3.0.0-beta.2", "type": "module", "license": "MIT", "author": "Evan You", @@ -48,7 +48,7 @@ "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript", "build-types": "run-s build-temp-types patch-types roll-types check-dist-types", "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node", - "patch-types": "esno scripts/patchTypes.ts", + "patch-types": "tsx scripts/patchTypes.ts", "roll-types": "api-extractor run && rimraf temp", "check-dist-types": "tsc --project tsconfig.check.json", "lint": "eslint --cache --ext .ts src/**", @@ -71,7 +71,7 @@ "@babel/types": "^7.18.4", "@jridgewell/trace-mapping": "^0.3.13", "@rollup/plugin-alias": "^3.1.9", - "@rollup/plugin-commonjs": "^21.1.0", + "@rollup/plugin-commonjs": "^22.0.1", "@rollup/plugin-dynamic-import-vars": "^1.4.3", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "13.3.0", @@ -90,7 +90,6 @@ "dotenv": "^14.3.2", "dotenv-expand": "^5.1.0", "es-module-lexer": "^0.10.5", - "esno": "^0.16.3", "estree-walker": "^3.0.1", "etag": "^1.8.1", "fast-glob": "^3.2.11", diff --git a/packages/vite/rollup.config.ts b/packages/vite/rollup.config.ts index fc51e94c299e3c..8c3e2642d542b9 100644 --- a/packages/vite/rollup.config.ts +++ b/packages/vite/rollup.config.ts @@ -134,15 +134,11 @@ function createNodePlugins( }, // postcss-load-config calls require after register ts-node 'postcss-load-config/src/index.js': { - src: `require(configFile)`, - replacement: `__require(configFile)` - }, - // @rollup/plugin-commonjs uses incorrect esm - '@rollup/plugin-commonjs/dist/index.es.js': { - src: `import { sync } from 'resolve';`, - replacement: `import __resolve from 'resolve';const sync = __resolve.sync;` + pattern: /require(?=\((configFile|'ts-node')\))/g, + replacement: `eval('require')` } }), + commonjs({ extensions: ['.js'], // Optional peer deps of ws. Native deps that are mostly for performance. diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index ceccdf345fbce4..509b5048da6d47 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -9,7 +9,7 @@ import '@vite/env' declare const __BASE__: string declare const __HMR_PROTOCOL__: string | null declare const __HMR_HOSTNAME__: string | null -declare const __HMR_PORT__: string | null +declare const __HMR_PORT__: number | null declare const __HMR_DIRECT_TARGET__: string declare const __HMR_BASE__: string declare const __HMR_TIMEOUT__: number diff --git a/packages/vite/src/node/__tests__/plugins/esbuild.spec.ts b/packages/vite/src/node/__tests__/plugins/esbuild.spec.ts new file mode 100644 index 00000000000000..50e9183b46e64c --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/esbuild.spec.ts @@ -0,0 +1,184 @@ +import { describe, expect, test } from 'vitest' +import type { ResolvedConfig, UserConfig } from '../../config' +import { resolveEsbuildTranspileOptions } from '../../plugins/esbuild' + +describe('resolveEsbuildTranspileOptions', () => { + test('resolve default', () => { + const options = resolveEsbuildTranspileOptions( + defineResolvedConfig({ + build: { + target: 'es2020', + minify: 'esbuild' + }, + esbuild: { + keepNames: true + } + }), + 'es' + ) + expect(options).toEqual({ + target: 'es2020', + format: 'esm', + keepNames: true, + minify: true, + treeShaking: true + }) + }) + + test('resolve esnext no minify', () => { + const options = resolveEsbuildTranspileOptions( + defineResolvedConfig({ + build: { + target: 'esnext', + minify: false + }, + esbuild: { + keepNames: true + } + }), + 'es' + ) + expect(options).toEqual(null) + }) + + test('resolve no minify', () => { + const options = resolveEsbuildTranspileOptions( + defineResolvedConfig({ + build: { + target: 'es2020', + minify: false + }, + esbuild: { + keepNames: true + } + }), + 'es' + ) + expect(options).toEqual({ + target: 'es2020', + format: 'esm', + keepNames: true, + minify: false, + minifyIdentifiers: false, + minifySyntax: false, + minifyWhitespace: false, + treeShaking: false + }) + }) + + test('resolve es lib', () => { + const options = resolveEsbuildTranspileOptions( + defineResolvedConfig({ + build: { + minify: 'esbuild', + lib: { + entry: './somewhere.js' + } + }, + esbuild: { + keepNames: true + } + }), + 'es' + ) + expect(options).toEqual({ + target: undefined, + format: 'esm', + keepNames: true, + minify: false, + minifyIdentifiers: true, + minifySyntax: true, + minifyWhitespace: false, + treeShaking: true + }) + }) + + test('resolve cjs lib', () => { + const options = resolveEsbuildTranspileOptions( + defineResolvedConfig({ + build: { + minify: 'esbuild', + lib: { + entry: './somewhere.js' + } + }, + esbuild: { + keepNames: true + } + }), + 'cjs' + ) + expect(options).toEqual({ + target: undefined, + format: 'cjs', + keepNames: true, + minify: true, + treeShaking: true + }) + }) + + test('resolve es lib with specific minify options', () => { + const options = resolveEsbuildTranspileOptions( + defineResolvedConfig({ + build: { + minify: 'esbuild', + lib: { + entry: './somewhere.js' + } + }, + esbuild: { + keepNames: true, + minifyIdentifiers: true, + minifyWhitespace: true + } + }), + 'es' + ) + expect(options).toEqual({ + target: undefined, + format: 'esm', + keepNames: true, + minify: false, + minifyIdentifiers: true, + minifyWhitespace: false, + treeShaking: true + }) + }) + + test('resolve cjs lib with specific minify options', () => { + const options = resolveEsbuildTranspileOptions( + defineResolvedConfig({ + build: { + minify: 'esbuild', + lib: { + entry: './somewhere.js' + } + }, + esbuild: { + keepNames: true, + minifyIdentifiers: true, + minifyWhitespace: true, + treeShaking: true + } + }), + 'cjs' + ) + expect(options).toEqual({ + target: undefined, + format: 'cjs', + keepNames: true, + minify: false, + minifyIdentifiers: true, + minifyWhitespace: true, + treeShaking: true + }) + }) +}) + +/** + * Helper for `resolveEsbuildTranspileOptions` to created resolved config with types. + * Note: The function only uses `build.target`, `build.minify` and `esbuild` options. + */ +function defineResolvedConfig(config: UserConfig): ResolvedConfig { + return config as any +} diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap index 61ff6eeb4d2fc7..3efbb7a0306f86 100644 --- a/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap +++ b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap @@ -1,162 +1,44 @@ // Vitest Snapshot v1 exports[`fixture > transform 1`] = ` -"import * as __vite_glob_1_0 from \\"./modules/a.ts\\" -import * as __vite_glob_1_1 from \\"./modules/b.ts\\" -import * as __vite_glob_1_2 from \\"./modules/index.ts\\" -import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\" -import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\" -import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\" -import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\" -import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\" -import \\"../../../../../../types/importMeta\\"; -export const basic = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), -\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\") -}); -export const basicEager = Object.assign({ -\\"./modules/a.ts\\": __vite_glob_1_0, -\\"./modules/b.ts\\": __vite_glob_1_1, -\\"./modules/index.ts\\": __vite_glob_1_2 -}); -export const ignore = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\") -}); -export const namedEager = Object.assign({ -\\"./modules/a.ts\\": __vite_glob_3_0, -\\"./modules/b.ts\\": __vite_glob_3_1, -\\"./modules/index.ts\\": __vite_glob_3_2 -}); -export const namedDefault = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]), -\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"]) -}); -export const eagerAs = Object.assign({ -\\"./modules/a.ts\\": __vite_glob_5_0, -\\"./modules/b.ts\\": __vite_glob_5_1 -}); -export const rawImportModule = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\") -}); -export const excludeSelf = Object.assign({ -\\"./sibling.ts\\": () => import(\\"./sibling.ts\\") -}); -export const customQueryString = Object.assign({ -\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom\\") -}); -export const customQueryObject = Object.assign({ -\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true\\") -}); -export const parent = Object.assign({ - -}); -export const rootMixedRelative = Object.assign({ -\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url\\").then(m => m[\\"default\\"]), -\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url\\").then(m => m[\\"default\\"]), -\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url\\").then(m => m[\\"default\\"]), -\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url\\").then(m => m[\\"default\\"]), -\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url\\").then(m => m[\\"default\\"]), -\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url\\").then(m => m[\\"default\\"]) -}); -export const cleverCwd1 = Object.assign({ -\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\") -}); -export const cleverCwd2 = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), -\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"), -\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\") -}); +"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";import \\"../../../../../../types/importMeta\\"; +export const basic = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")}); +export const basicEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_1_0,\\"./modules/b.ts\\": __vite_glob_1_1,\\"./modules/index.ts\\": __vite_glob_1_2}); +export const ignore = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")}); +export const namedEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_3_0,\\"./modules/b.ts\\": __vite_glob_3_1,\\"./modules/index.ts\\": __vite_glob_3_2}); +export const namedDefault = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"])}); +export const eagerAs = Object.assign({\\"./modules/a.ts\\": __vite_glob_5_0,\\"./modules/b.ts\\": __vite_glob_5_1}); +export const rawImportModule = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\")}); +export const excludeSelf = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts\\")}); +export const customQueryString = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom\\")}); +export const customQueryObject = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true\\")}); +export const parent = Object.assign({}); +export const rootMixedRelative = Object.assign({\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/esbuild.spec.ts\\": () => import(\\"../../esbuild.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url\\").then(m => m[\\"default\\"])}); +export const cleverCwd1 = Object.assign({\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\")}); +export const cleverCwd2 = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"),\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\")}); " `; exports[`fixture > transform with restoreQueryExtension 1`] = ` -"import * as __vite_glob_1_0 from \\"./modules/a.ts\\" -import * as __vite_glob_1_1 from \\"./modules/b.ts\\" -import * as __vite_glob_1_2 from \\"./modules/index.ts\\" -import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\" -import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\" -import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\" -import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\" -import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\" -import \\"../../../../../../types/importMeta\\"; -export const basic = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), -\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\") -}); -export const basicEager = Object.assign({ -\\"./modules/a.ts\\": __vite_glob_1_0, -\\"./modules/b.ts\\": __vite_glob_1_1, -\\"./modules/index.ts\\": __vite_glob_1_2 -}); -export const ignore = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\") -}); -export const namedEager = Object.assign({ -\\"./modules/a.ts\\": __vite_glob_3_0, -\\"./modules/b.ts\\": __vite_glob_3_1, -\\"./modules/index.ts\\": __vite_glob_3_2 -}); -export const namedDefault = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]), -\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"]) -}); -export const eagerAs = Object.assign({ -\\"./modules/a.ts\\": __vite_glob_5_0, -\\"./modules/b.ts\\": __vite_glob_5_1 -}); -export const rawImportModule = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\") -}); -export const excludeSelf = Object.assign({ -\\"./sibling.ts\\": () => import(\\"./sibling.ts\\") -}); -export const customQueryString = Object.assign({ -\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom&lang.ts\\") -}); -export const customQueryObject = Object.assign({ -\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true&lang.ts\\") -}); -export const parent = Object.assign({ - -}); -export const rootMixedRelative = Object.assign({ -\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]), -\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]), -\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]), -\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url&lang.ts\\").then(m => m[\\"default\\"]), -\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url&lang.ts\\").then(m => m[\\"default\\"]), -\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url&lang.ts\\").then(m => m[\\"default\\"]) -}); -export const cleverCwd1 = Object.assign({ -\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\") -}); -export const cleverCwd2 = Object.assign({ -\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), -\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), -\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"), -\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\") -}); +"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";import \\"../../../../../../types/importMeta\\"; +export const basic = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")}); +export const basicEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_1_0,\\"./modules/b.ts\\": __vite_glob_1_1,\\"./modules/index.ts\\": __vite_glob_1_2}); +export const ignore = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")}); +export const namedEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_3_0,\\"./modules/b.ts\\": __vite_glob_3_1,\\"./modules/index.ts\\": __vite_glob_3_2}); +export const namedDefault = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"])}); +export const eagerAs = Object.assign({\\"./modules/a.ts\\": __vite_glob_5_0,\\"./modules/b.ts\\": __vite_glob_5_1}); +export const rawImportModule = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\")}); +export const excludeSelf = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts\\")}); +export const customQueryString = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom&lang.ts\\")}); +export const customQueryObject = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true&lang.ts\\")}); +export const parent = Object.assign({}); +export const rootMixedRelative = Object.assign({\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/esbuild.spec.ts\\": () => import(\\"../../esbuild.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url&lang.ts\\").then(m => m[\\"default\\"])}); +export const cleverCwd1 = Object.assign({\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\")}); +export const cleverCwd2 = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"),\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\")}); " `; exports[`fixture > virtual modules 1`] = ` -"Object.assign({ -\\"/modules/a.ts\\": () => import(\\"/modules/a.ts\\"), -\\"/modules/b.ts\\": () => import(\\"/modules/b.ts\\"), -\\"/modules/index.ts\\": () => import(\\"/modules/index.ts\\") -}) -Object.assign({ -\\"/../fixture-b/a.ts\\": () => import(\\"/../fixture-b/a.ts\\"), -\\"/../fixture-b/b.ts\\": () => import(\\"/../fixture-b/b.ts\\"), -\\"/../fixture-b/index.ts\\": () => import(\\"/../fixture-b/index.ts\\") -})" +"Object.assign({\\"/modules/a.ts\\": () => import(\\"/modules/a.ts\\"),\\"/modules/b.ts\\": () => import(\\"/modules/b.ts\\"),\\"/modules/index.ts\\": () => import(\\"/modules/index.ts\\")}) +Object.assign({\\"/../fixture-b/a.ts\\": () => import(\\"/../fixture-b/a.ts\\"),\\"/../fixture-b/b.ts\\": () => import(\\"/../fixture-b/b.ts\\"),\\"/../fixture-b/index.ts\\": () => import(\\"/../fixture-b/index.ts\\")})" `; diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 06b222736667c8..1e7b9583a618ea 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -29,6 +29,7 @@ import { dynamicImport, isExternalUrl, isObject, + isTS, lookupFile, mergeAlias, mergeConfig, @@ -37,7 +38,12 @@ import { } from './utils' import { resolvePlugins } from './plugins' import type { ESBuildOptions } from './plugins/esbuild' -import { CLIENT_ENTRY, DEFAULT_ASSETS_RE, ENV_ENTRY } from './constants' +import { + CLIENT_ENTRY, + DEFAULT_ASSETS_RE, + DEFAULT_CONFIG_FILES, + ENV_ENTRY +} from './constants' import type { InternalResolveOptions, ResolveOptions } from './plugins/resolve' import { resolvePlugin } from './plugins/resolve' import type { LogLevel, Logger } from './logger' @@ -588,6 +594,13 @@ export async function resolveConfig( config = mergeConfig(config, externalConfigCompat(config, configEnv)) const optimizeDeps = config.optimizeDeps || {} + if (process.env.VITE_TEST_LEGACY_CJS_PLUGIN) { + config.legacy = { + ...config.legacy, + buildRollupPluginCommonjs: true + } + } + const BASE_URL = resolvedBase const resolved: ResolvedConfig = { @@ -825,56 +838,20 @@ export async function loadConfigFromFile( const getTime = () => `${(performance.now() - start).toFixed(2)}ms` let resolvedPath: string | undefined - let isTS = false - let isESM = false let dependencies: string[] = [] - // check package.json for type: "module" and set `isMjs` to true - try { - const pkg = lookupFile(configRoot, ['package.json']) - if (pkg && JSON.parse(pkg).type === 'module') { - isESM = true - } - } catch (e) {} - if (configFile) { // explicit config path is always resolved from cwd resolvedPath = path.resolve(configFile) - isTS = configFile.endsWith('.ts') - - if (configFile.endsWith('.mjs')) { - isESM = true - } } else { // implicit config file loaded from inline root (if present) // otherwise from cwd - const jsconfigFile = path.resolve(configRoot, 'vite.config.js') - if (fs.existsSync(jsconfigFile)) { - resolvedPath = jsconfigFile - } - - if (!resolvedPath) { - const mjsconfigFile = path.resolve(configRoot, 'vite.config.mjs') - if (fs.existsSync(mjsconfigFile)) { - resolvedPath = mjsconfigFile - isESM = true - } - } - - if (!resolvedPath) { - const tsconfigFile = path.resolve(configRoot, 'vite.config.ts') - if (fs.existsSync(tsconfigFile)) { - resolvedPath = tsconfigFile - isTS = true - } - } + for (const filename of DEFAULT_CONFIG_FILES) { + const filePath = path.resolve(configRoot, filename) + if (!fs.existsSync(filePath)) continue - if (!resolvedPath) { - const cjsConfigFile = path.resolve(configRoot, 'vite.config.cjs') - if (fs.existsSync(cjsConfigFile)) { - resolvedPath = cjsConfigFile - isESM = false - } + resolvedPath = filePath + break } } @@ -883,6 +860,19 @@ export async function loadConfigFromFile( return null } + let isESM = false + if (/\.m[jt]s$/.test(resolvedPath)) { + isESM = true + } else if (/\.c[jt]s$/.test(resolvedPath)) { + isESM = false + } else { + // check package.json for type: "module" and set `isESM` to true + try { + const pkg = lookupFile(configRoot, ['package.json']) + isESM = !!pkg && JSON.parse(pkg).type === 'module' + } catch (e) {} + } + try { let userConfig: UserConfigExport | undefined @@ -890,15 +880,19 @@ export async function loadConfigFromFile( const fileUrl = pathToFileURL(resolvedPath) const bundled = await bundleConfigFile(resolvedPath, true) dependencies = bundled.dependencies - if (isTS) { + + if (isTS(resolvedPath)) { // before we can register loaders without requiring users to run node // with --experimental-loader themselves, we have to do a hack here: // bundle the config file w/ ts transforms first, write it to disk, // load it with native Node ESM, then delete the file. - fs.writeFileSync(resolvedPath + '.js', bundled.code) - userConfig = (await dynamicImport(`${fileUrl}.js?t=${Date.now()}`)) - .default - fs.unlinkSync(resolvedPath + '.js') + fs.writeFileSync(resolvedPath + '.mjs', bundled.code) + try { + userConfig = (await dynamicImport(`${fileUrl}.mjs?t=${Date.now()}`)) + .default + } finally { + fs.unlinkSync(resolvedPath + '.mjs') + } debug(`TS + native esm config loaded in ${getTime()}`, fileUrl) } else { // using Function to avoid this from being compiled away by TS/Rollup @@ -972,7 +966,7 @@ async function bundleConfigFile( { name: 'inject-file-scope-variables', setup(build) { - build.onLoad({ filter: /\.[jt]s$/ }, async (args) => { + build.onLoad({ filter: /\.[cm]?[jt]s$/ }, async (args) => { const contents = await fs.promises.readFile(args.path, 'utf8') const injectValues = `const __dirname = ${JSON.stringify(path.dirname(args.path))};` + @@ -982,7 +976,7 @@ async function bundleConfigFile( )};` return { - loader: args.path.endsWith('.ts') ? 'ts' : 'js', + loader: isTS(args.path) ? 'ts' : 'js', contents: injectValues + contents } }) diff --git a/packages/vite/src/node/constants.ts b/packages/vite/src/node/constants.ts index b6840a63348c0f..12bc4f22c10038 100644 --- a/packages/vite/src/node/constants.ts +++ b/packages/vite/src/node/constants.ts @@ -30,6 +30,15 @@ export const DEFAULT_EXTENSIONS = [ '.json' ] +export const DEFAULT_CONFIG_FILES = [ + 'vite.config.js', + 'vite.config.mjs', + 'vite.config.ts', + 'vite.config.cjs', + 'vite.config.mts', + 'vite.config.cts' +] + export const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/ export const OPTIMIZABLE_ENTRY_RE = /\.(?:m?js|ts)$/ @@ -62,6 +71,7 @@ export const NULL_BYTE_PLACEHOLDER = `__x00__` export const CLIENT_PUBLIC_PATH = `/@vite/client` export const ENV_PUBLIC_PATH = `/@vite/env` export const VITE_PACKAGE_DIR = resolve( + // import.meta.url is `dist/node/constants.js` after bundle fileURLToPath(import.meta.url), '../../..' ) diff --git a/packages/vite/src/node/optimizer/esbuildDepPlugin.ts b/packages/vite/src/node/optimizer/esbuildDepPlugin.ts index 09866eb300c2a3..8803ae3a1f5c48 100644 --- a/packages/vite/src/node/optimizer/esbuildDepPlugin.ts +++ b/packages/vite/src/node/optimizer/esbuildDepPlugin.ts @@ -118,10 +118,16 @@ export function esbuildDepPlugin( const resolved = await resolve(id, importer, kind) if (resolved) { - // here it is not set to `external: true` to convert `require` to `import` + if (kind === 'require-call') { + // here it is not set to `external: true` to convert `require` to `import` + return { + path: resolved, + namespace: externalWithConversionNamespace + } + } return { path: resolved, - namespace: externalWithConversionNamespace + external: true } } } diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 8e0c37fb161e59..2c56f04aba491a 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -62,6 +62,7 @@ export interface DepsOptimizer { delayDepsOptimizerUntil: (id: string, done: () => Promise) => void registerWorkersSource: (id: string) => void resetRegisteredIds: () => void + ensureFirstRun: () => void options: DepOptimizationOptions } diff --git a/packages/vite/src/node/optimizer/optimizer.ts b/packages/vite/src/node/optimizer/optimizer.ts index 5592c438ece552..37a3aef745b4f3 100644 --- a/packages/vite/src/node/optimizer/optimizer.ts +++ b/packages/vite/src/node/optimizer/optimizer.ts @@ -1,6 +1,8 @@ +import path from 'node:path' import colors from 'picocolors' import _debug from 'debug' import glob from 'fast-glob' +import { FS_PREFIX } from '../constants' import { getHash } from '../utils' import { transformRequest } from '../server/transformRequest' import type { ResolvedConfig, ViteDevServer } from '..' @@ -81,6 +83,7 @@ export async function initDepsOptimizer( registerWorkersSource, delayDepsOptimizerUntil, resetRegisteredIds, + ensureFirstRun, options: config.optimizeDeps } @@ -519,12 +522,28 @@ export async function initDepsOptimizer( let seenIds = new Set() let workersSources = new Set() let waitingOn: string | undefined + let firstRunEnsured = false function resetRegisteredIds() { registeredIds = [] seenIds = new Set() workersSources = new Set() waitingOn = undefined + firstRunEnsured = false + } + + // If all the inputs are dependencies, we aren't going to get any + // delayDepsOptimizerUntil(id) calls. We need to guard against this + // by forcing a rerun if no deps have been registered + function ensureFirstRun() { + if (!firstRunEnsured && !firstRunCalled && registeredIds.length === 0) { + setTimeout(() => { + if (!firstRunCalled && registeredIds.length === 0) { + getDepsOptimizer(config)?.run() + } + }, runOptimizerIfIdleAfterMs) + } + firstRunEnsured = true } function registerWorkersSource(id: string): void { @@ -557,7 +576,7 @@ export async function initDepsOptimizer( waitingOn = next.id const afterLoad = () => { waitingOn = undefined - if (!workersSources.has(next.id)) { + if (!firstRunCalled && !workersSources.has(next.id)) { if (registeredIds.length > 0) { runOptimizerWhenIdle() } else { @@ -585,17 +604,21 @@ export async function preTransformOptimizeDepsEntries( server: ViteDevServer ): Promise { const { config } = server + const { root } = config const { entries } = config.optimizeDeps if (entries) { const explicitEntries = await glob(entries, { - cwd: config.root, + cwd: root, ignore: ['**/node_modules/**', `**/${config.build.outDir}/**`], absolute: true }) // TODO: should we restrict the entries to JS and HTML like the // scanner did? I think we can let the user chose any entry for (const entry of explicitEntries) { - transformRequest(entry, server, { ssr: false }).catch((e) => { + const url = entry.startsWith(root + '/') + ? entry.slice(root.length) + : path.posix.join(FS_PREFIX + entry) + transformRequest(url, server, { ssr: false }).catch((e) => { config.logger.error(e.message) }) } diff --git a/packages/vite/src/node/plugin.ts b/packages/vite/src/node/plugin.ts index 40845bf1f2dcfc..69b19415b0daa7 100644 --- a/packages/vite/src/node/plugin.ts +++ b/packages/vite/src/node/plugin.ts @@ -128,7 +128,7 @@ export interface Plugin extends RollupPlugin { /** * extend hooks with ssr flag */ - resolveId?( + resolveId?: ( this: PluginContext, source: string, importer: string | undefined, @@ -139,17 +139,18 @@ export interface Plugin extends RollupPlugin { * @internal */ scan?: boolean + isEntry: boolean } - ): Promise | ResolveIdResult - load?( + ) => Promise | ResolveIdResult + load?: ( this: PluginContext, id: string, options?: { ssr?: boolean } - ): Promise | LoadResult - transform?( + ) => Promise | LoadResult + transform?: ( this: TransformPluginContext, code: string, id: string, options?: { ssr?: boolean } - ): Promise | TransformResult + ) => Promise | TransformResult } diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index cab050cbdfa652..ec8ec66ff0dd21 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -383,6 +383,7 @@ async function fileToBuiltUrl( if ( config.build.lib || (!file.endsWith('.svg') && + !file.endsWith('.html') && content.length < Number(config.build.assetsInlineLimit)) ) { const mimeType = mrmime.lookup(file) ?? 'application/octet-stream' diff --git a/packages/vite/src/node/plugins/assetImportMetaUrl.ts b/packages/vite/src/node/plugins/assetImportMetaUrl.ts index af3fa325bfce03..6d7a657706cf9c 100644 --- a/packages/vite/src/node/plugins/assetImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/assetImportMetaUrl.ts @@ -3,7 +3,7 @@ import MagicString from 'magic-string' import { stripLiteral } from 'strip-literal' import type { Plugin } from '../plugin' import type { ResolvedConfig } from '../config' -import { transformResult } from '../utils' +import { transformStableResult } from '../utils' import { fileToUrl } from './asset' import { preloadHelperId } from './importAnalysisBuild' @@ -81,7 +81,7 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin { ) } if (s) { - return transformResult(s, id, config) + return transformStableResult(s, id, config) } } return null diff --git a/packages/vite/src/node/plugins/clientInjections.ts b/packages/vite/src/node/plugins/clientInjections.ts index d63c72d6143216..4eb1654d09d7a8 100644 --- a/packages/vite/src/node/plugins/clientInjections.ts +++ b/packages/vite/src/node/plugins/clientInjections.ts @@ -26,11 +26,9 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin { // hmr.clientPort -> hmr.port // -> (24678 if middleware mode) -> new URL(import.meta.url).port - let port = hmrConfig - ? String(hmrConfig.clientPort || hmrConfig.port) - : null + let port = hmrConfig?.clientPort || hmrConfig?.port || null if (config.server.middlewareMode) { - port ||= '24678' + port ||= 24678 } const devBase = config.base diff --git a/packages/vite/src/node/plugins/define.ts b/packages/vite/src/node/plugins/define.ts index 9859676e693a23..1baff98c9b5ad0 100644 --- a/packages/vite/src/node/plugins/define.ts +++ b/packages/vite/src/node/plugins/define.ts @@ -1,7 +1,7 @@ import MagicString from 'magic-string' -import type { TransformResult } from 'rollup' import type { ResolvedConfig } from '../config' import type { Plugin } from '../plugin' +import { transformStableResult } from '../utils' import { isCSSRequest } from './css' import { isHTMLRequest } from './html' @@ -144,11 +144,7 @@ export function definePlugin(config: ResolvedConfig): Plugin { return null } - const result: TransformResult = { code: s.toString() } - if (config.build.sourcemap) { - result.map = s.generateMap({ hires: true }) - } - return result + return transformStableResult(s, id, config) } } } diff --git a/packages/vite/src/node/plugins/dynamicImportVars.ts b/packages/vite/src/node/plugins/dynamicImportVars.ts index 7093ded9253a39..97f605c1758d53 100644 --- a/packages/vite/src/node/plugins/dynamicImportVars.ts +++ b/packages/vite/src/node/plugins/dynamicImportVars.ts @@ -11,7 +11,7 @@ import { normalizePath, parseRequest, requestQuerySplitRE, - transformResult + transformStableResult } from '../utils' export const dynamicImportHelperId = '/@vite/dynamic-import-helper' @@ -209,7 +209,7 @@ export function dynamicImportVarsPlugin(config: ResolvedConfig): Plugin { `import __variableDynamicImportRuntimeHelper from "${dynamicImportHelperId}";` ) } - return transformResult(s, importer, config) + return transformStableResult(s, importer, config) } } } diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index 16c165bf288a98..ee1c36db651849 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -8,7 +8,7 @@ import type { } from 'esbuild' import { transform } from 'esbuild' import type { RawSourceMap } from '@ampproject/remapping' -import type { SourceMap } from 'rollup' +import type { InternalModuleFormat, SourceMap } from 'rollup' import type { TSConfckParseOptions, TSConfckParseResult } from 'tsconfck' import { TSConfckParseError, findAll, parse } from 'tsconfck' import { @@ -27,9 +27,9 @@ import { searchForWorkspaceRoot } from '..' const debug = createDebugger('vite:esbuild') const INJECT_HELPERS_IIFE_RE = - /(.*)((?:const|var) [^\s]+=function\([^)]*?\){"use strict";)(.*)/s + /^(.*)((?:const|var) [^\s]+=function\([^)]*?\){"use strict";)/s const INJECT_HELPERS_UMD_RE = - /(.*)(\(function\([^)]*?\){.+amd.+function\([^)]*?\){"use strict";)(.*)/s + /^(.*)(\(function\([^)]*?\){.+amd.+function\([^)]*?\){"use strict";)/s let server: ViteDevServer @@ -37,6 +37,10 @@ export interface ESBuildOptions extends TransformOptions { include?: string | RegExp | string[] | RegExp[] exclude?: string | RegExp | string[] | RegExp[] jsxInject?: string + /** + * This option is not respected. Use `build.minify` instead. + */ + minify?: never } export type ESBuildTransformResult = Omit & { @@ -170,6 +174,17 @@ export function esbuildPlugin(options: ESBuildOptions = {}): Plugin { options.exclude || /\.js$/ ) + // Remove optimization options for dev as we only need to transpile them, + // and for build as the final optimization is in `buildEsbuildPlugin` + const transformOptions: TransformOptions = { + ...options, + minify: false, + minifyIdentifiers: false, + minifySyntax: false, + minifyWhitespace: false, + treeShaking: false + } + return { name: 'vite:esbuild', configureServer(_server) { @@ -188,7 +203,7 @@ export function esbuildPlugin(options: ESBuildOptions = {}): Plugin { }, async transform(code, id) { if (filter(id) || filter(cleanUrl(id))) { - const result = await transformWithEsbuild(code, id, options) + const result = await transformWithEsbuild(code, id, transformOptions) if (result.warnings.length) { result.warnings.forEach((m) => { this.warn(prettifyMessage(m, code)) @@ -236,29 +251,13 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => { return null } - const target = config.build.target - const minify = - config.build.minify === 'esbuild' && - // Do not minify ES lib output since that would remove pure annotations - // and break tree-shaking - // https://github.com/vuejs/core/issues/2860#issuecomment-926882793 - !(config.build.lib && opts.format === 'es') + const options = resolveEsbuildTranspileOptions(config, opts.format) - if ((!target || target === 'esnext') && !minify) { + if (!options) { return null } - const res = await transformWithEsbuild(code, chunk.fileName, { - ...config.esbuild, - target: target || undefined, - ...(minify - ? { - minify, - treeShaking: true, - format: rollupToEsbuildFormatMap[opts.format] - } - : undefined) - }) + const res = await transformWithEsbuild(code, chunk.fileName, options) if (config.build.lib) { // #7188, esbuild adds helpers out of the UMD and IIFE wrappers, and the @@ -275,7 +274,7 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => { if (injectHelpers) { res.code = res.code.replace( injectHelpers, - (_, helpers, header, rest) => header + helpers + rest + (_, helpers, header) => header + helpers ) } } @@ -284,6 +283,82 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => { } } +export function resolveEsbuildTranspileOptions( + config: ResolvedConfig, + format: InternalModuleFormat +): TransformOptions | null { + const target = config.build.target + const minify = config.build.minify === 'esbuild' + + if ((!target || target === 'esnext') && !minify) { + return null + } + + // Do not minify whitespace for ES lib output since that would remove + // pure annotations and break tree-shaking + // https://github.com/vuejs/core/issues/2860#issuecomment-926882793 + const isEsLibBuild = config.build.lib && format === 'es' + const options: TransformOptions = { + ...config.esbuild, + target: target || undefined, + format: rollupToEsbuildFormatMap[format] + } + + // If no minify, disable all minify options + if (!minify) { + return { + ...options, + minify: false, + minifyIdentifiers: false, + minifySyntax: false, + minifyWhitespace: false, + treeShaking: false + } + } + + // If user enable fine-grain minify options, minify with their options instead + if ( + options.minifyIdentifiers || + options.minifySyntax || + options.minifyWhitespace + ) { + if (isEsLibBuild) { + // Disable minify whitespace as it breaks tree-shaking + return { + ...options, + minify: false, + minifyWhitespace: false, + treeShaking: true + } + } else { + return { + ...options, + minify: false, + treeShaking: true + } + } + } + + // Else apply default minify options + if (isEsLibBuild) { + // Minify all except whitespace as it breaks tree-shaking + return { + ...options, + minify: false, + minifyIdentifiers: true, + minifySyntax: true, + minifyWhitespace: false, + treeShaking: true + } + } else { + return { + ...options, + minify: true, + treeShaking: true + } + } +} + function prettifyMessage(m: Message, code: string): string { let res = colors.yellow(m.text) if (m.location) { diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index c7b4d5c8bb3f1b..9a39c792388400 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -40,7 +40,7 @@ import { removeImportQuery, stripBomTag, timeFrom, - transformResult, + transformStableResult, unwrapId } from '../utils' import type { ResolvedConfig } from '../config' @@ -711,7 +711,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { } if (s) { - return transformResult(s, importer, config) + return transformStableResult(s, importer, config) } else { return source } diff --git a/packages/vite/src/node/plugins/importMetaGlob.ts b/packages/vite/src/node/plugins/importMetaGlob.ts index 661093676626e6..7f3695178fdce9 100644 --- a/packages/vite/src/node/plugins/importMetaGlob.ts +++ b/packages/vite/src/node/plugins/importMetaGlob.ts @@ -17,7 +17,7 @@ import type { Plugin } from '../plugin' import type { ViteDevServer } from '../server' import type { ModuleNode } from '../server/moduleGraph' import type { ResolvedConfig } from '../config' -import { normalizePath, slash, transformResult } from '../utils' +import { normalizePath, slash, transformStableResult } from '../utils' const { isMatch, scan } = micromatch @@ -75,7 +75,7 @@ export function importGlobPlugin(config: ResolvedConfig): Plugin { server!.watcher.add(dirname(file)) }) } - return transformResult(result.s, id, config) + return transformStableResult(result.s, id, config) } } } @@ -426,7 +426,7 @@ export async function transformGlobImport( files.forEach((i) => matchedFiles.add(i)) - const replacement = `Object.assign({\n${objectProps.join(',\n')}\n})` + const replacement = `Object.assign({${objectProps.join(',')}})` s.overwrite(start, end, replacement) return staticImports @@ -435,7 +435,7 @@ export async function transformGlobImport( ) ).flat() - if (staticImports.length) s.prepend(`${staticImports.join('\n')}\n`) + if (staticImports.length) s.prepend(`${staticImports.join(';')};`) return { s, diff --git a/packages/vite/src/node/plugins/optimizedDeps.ts b/packages/vite/src/node/plugins/optimizedDeps.ts index 3eff36bd1bc13e..3db6d850f7f286 100644 --- a/packages/vite/src/node/plugins/optimizedDeps.ts +++ b/packages/vite/src/node/plugins/optimizedDeps.ts @@ -108,8 +108,12 @@ export function optimizedDepsBuildPlugin(config: ResolvedConfig): Plugin { if (!metadata || !depsOptimizer?.isOptimizedDepFile(id)) { return } + + depsOptimizer?.ensureFirstRun() + const file = cleanUrl(id) // Search in both the currently optimized and newly discovered deps + // If all the inputs are dependencies, we aren't going to get any const info = optimizedDepInfoFromFile(metadata, file) if (info) { try { diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts index c88046465f0f42..1b05e6d4a137e1 100644 --- a/packages/vite/src/node/plugins/workerImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -10,7 +10,7 @@ import { injectQuery, normalizePath, parseRequest, - transformResult + transformStableResult } from '../utils' import { getDepsOptimizer } from '../optimizer' import type { WorkerType } from './worker' @@ -136,7 +136,7 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { } if (s) { - return transformResult(s, id, config) + return transformStableResult(s, id, config) } return null diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 9227746eb23c4c..1ca05bd28651b2 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -718,7 +718,7 @@ async function restartServer(server: ViteDevServer) { // prevent new server `restart` function from calling // @ts-ignore newServer[key] = server[key] - } else if (key !== 'app') { + } else { // @ts-ignore server[key] = newServer[key] } diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index 86dcefe024542f..0a708ed62c4e6c 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -97,6 +97,7 @@ export interface PluginContainer { * @internal */ scan?: boolean + isEntry?: boolean } ): Promise transform( @@ -527,6 +528,7 @@ export async function createPluginContainer( const skip = options?.skip const ssr = options?.ssr const scan = !!options?.scan + const isEntry = !!options?.isEntry const ctx = new Context() ctx.ssr = !!ssr ctx._scan = scan @@ -546,7 +548,7 @@ export async function createPluginContainer( ctx as any, rawId, importer, - { ssr, scan } + { ssr, scan, isEntry } ) if (!result) continue diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 5967aadfc29f58..e2c7c8862b930a 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -1028,16 +1028,21 @@ function normalizeSingleAlias({ return alias } -export function transformResult( +/** + * Transforms transpiled code result where line numbers aren't altered, + * so we can skip sourcemap generation during dev + */ +export function transformStableResult( s: MagicString, id: string, config: ResolvedConfig ): TransformResult { - const isBuild = config.command === 'build' - const needSourceMap = !isBuild || config.build.sourcemap return { code: s.toString(), - map: needSourceMap ? s.generateMap({ hires: true, source: id }) : null + map: + config.command === 'build' && config.build.sourcemap + ? s.generateMap({ hires: true, source: id }) + : null } } @@ -1056,3 +1061,5 @@ export function stripBomTag(content: string): string { return content } + +export const isTS = (filename: string): boolean => /\.[cm]?ts$/.test(filename) diff --git a/packages/vite/tsconfig.check.json b/packages/vite/tsconfig.check.json index cd8f8d6eeb3f2c..d1e9f059c9409c 100644 --- a/packages/vite/tsconfig.check.json +++ b/packages/vite/tsconfig.check.json @@ -14,7 +14,9 @@ // indirect: postcss depends on it "source-map-js": ["./node_modules/source-map-js/source-map.d.ts"] }, - "typeRoots": [] + "typeRoots": [], + "strict": true, + "exactOptionalPropertyTypes": true }, "include": ["dist/**/*.d.ts"] } diff --git a/playground/external/dep-that-imports-vue/package.json b/playground/external/dep-that-imports-vue/package.json index 2c088c73cbb035..0fcd4b186a979b 100644 --- a/playground/external/dep-that-imports-vue/package.json +++ b/playground/external/dep-that-imports-vue/package.json @@ -1,6 +1,7 @@ { "name": "@vitejs/dep-that-imports-vue", - "version": "0.0.1", + "private": true, + "version": "0.0.0", "dependencies": { "vue": "^3.2.37" } diff --git a/playground/external/dep-that-requires-vue/package.json b/playground/external/dep-that-requires-vue/package.json index a12c43b40fb282..a71847a02bb969 100644 --- a/playground/external/dep-that-requires-vue/package.json +++ b/playground/external/dep-that-requires-vue/package.json @@ -1,6 +1,7 @@ { "name": "@vitejs/dep-that-requires-vue", - "version": "0.0.1", + "private": true, + "version": "0.0.0", "dependencies": { "vue": "^3.2.37" } diff --git a/playground/external/vite.config.js b/playground/external/vite.config.js index f6126b069cf49d..fde8e763f810e0 100644 --- a/playground/external/vite.config.js +++ b/playground/external/vite.config.js @@ -5,6 +5,9 @@ export default defineConfig({ minify: false, rollupOptions: { external: ['vue'] + }, + commonjsOptions: { + esmExternals: ['vue'] } } }) diff --git a/playground/optimize-deps/__tests__/optimize-deps.spec.ts b/playground/optimize-deps/__tests__/optimize-deps.spec.ts index df1713b3fc76f8..b0af6debca526e 100644 --- a/playground/optimize-deps/__tests__/optimize-deps.spec.ts +++ b/playground/optimize-deps/__tests__/optimize-deps.spec.ts @@ -103,11 +103,16 @@ test('vue + vuex', async () => { expect(await page.textContent('.vue')).toMatch(`[success]`) }) -test('esbuild-plugin', async () => { - expect(await page.textContent('.esbuild-plugin')).toMatch( - `Hello from an esbuild plugin` - ) -}) +// When we use the Rollup CommonJS plugin instead of esbuild prebundling, +// the esbuild plugins won't apply to dependencies +test.skipIf(isBuild && process.env.VITE_TEST_LEGACY_CJS_PLUGIN)( + 'esbuild-plugin', + async () => { + expect(await page.textContent('.esbuild-plugin')).toMatch( + `Hello from an esbuild plugin` + ) + } +) test('import from hidden dir', async () => { expect(await page.textContent('.hidden-dir')).toBe('hello!') diff --git a/playground/optimize-deps/vite.config.js b/playground/optimize-deps/vite.config.js index e268510d5c8d76..133d0da1e32b74 100644 --- a/playground/optimize-deps/vite.config.js +++ b/playground/optimize-deps/vite.config.js @@ -72,7 +72,7 @@ module.exports = { apply: 'build', enforce: 'pre', load(id) { - if (id === '__vite-browser-external:fs') { + if (id === '__vite-browser-external') { return `export default {}; export function readFileSync() {}` } } diff --git a/playground/react-classic/App.jsx b/playground/react-classic/App.jsx new file mode 100644 index 00000000000000..1de7461b163776 --- /dev/null +++ b/playground/react-classic/App.jsx @@ -0,0 +1,30 @@ +import { useState } from 'react' + +function App() { + const [count, setCount] = useState(0) + return ( +
+
+

Hello Vite + React

+

+ +

+

+ Edit App.jsx and save to test HMR updates. +

+ + Learn React + +
+
+ ) +} + +export default App diff --git a/playground/react-classic/__tests__/react.spec.ts b/playground/react-classic/__tests__/react.spec.ts new file mode 100644 index 00000000000000..8381992d59df3d --- /dev/null +++ b/playground/react-classic/__tests__/react.spec.ts @@ -0,0 +1,38 @@ +import { editFile, isServe, page, untilUpdated } from '~utils' + +test('should render', async () => { + expect(await page.textContent('h1')).toMatch('Hello Vite + React') +}) + +test('should update', async () => { + expect(await page.textContent('button')).toMatch('count is: 0') + await page.click('button') + expect(await page.textContent('button')).toMatch('count is: 1') +}) + +test('should hmr', async () => { + editFile('App.jsx', (code) => code.replace('Vite + React', 'Updated')) + await untilUpdated(() => page.textContent('h1'), 'Hello Updated') + // preserve state + expect(await page.textContent('button')).toMatch('count is: 1') +}) + +test.runIf(isServe)( + 'should have annotated jsx with file location metadata', + async () => { + const meta = await page.evaluate(() => { + const button = document.querySelector('button') + const key = Object.keys(button).find( + (key) => key.indexOf('__reactFiber') === 0 + ) + return button[key]._debugSource + }) + // If the evaluate call doesn't crash, and the returned metadata has + // the expected fields, we're good. + expect(Object.keys(meta).sort()).toEqual([ + 'columnNumber', + 'fileName', + 'lineNumber' + ]) + } +) diff --git a/playground/react-classic/index.html b/playground/react-classic/index.html new file mode 100644 index 00000000000000..f0015ceb9829a3 --- /dev/null +++ b/playground/react-classic/index.html @@ -0,0 +1,10 @@ +
+ diff --git a/playground/react-classic/package.json b/playground/react-classic/package.json new file mode 100644 index 00000000000000..a07684af1feefd --- /dev/null +++ b/playground/react-classic/package.json @@ -0,0 +1,23 @@ +{ + "name": "test-react-classic", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "debug": "node --inspect-brk ../../packages/vite/bin/vite", + "preview": "vite preview" + }, + "dependencies": { + "react": "^18.1.0", + "react-dom": "^18.1.0" + }, + "devDependencies": { + "@vitejs/plugin-react": "workspace:*" + }, + "babel": { + "presets": [ + "@babel/preset-env" + ] + } +} diff --git a/playground/react-classic/vite.config.ts b/playground/react-classic/vite.config.ts new file mode 100644 index 00000000000000..a2044e99ae2f3c --- /dev/null +++ b/playground/react-classic/vite.config.ts @@ -0,0 +1,16 @@ +import react from '@vitejs/plugin-react' +import type { UserConfig } from 'vite' + +const config: UserConfig = { + plugins: [ + react({ + jsxRuntime: 'classic' + }) + ], + build: { + // to make tests faster + minify: false + } +} + +export default config diff --git a/playground/resolve-config/__tests__/resolve-config.spec.ts b/playground/resolve-config/__tests__/resolve-config.spec.ts index 324d797ea31ad8..6682deb9805a34 100644 --- a/playground/resolve-config/__tests__/resolve-config.spec.ts +++ b/playground/resolve-config/__tests__/resolve-config.spec.ts @@ -49,4 +49,20 @@ describe.runIf(isBuild)('build', () => { build('ts-module') expect(getDistFile('ts-module', 'js')).toContain('console.log(true)') }) + it('loads vite.config.mts', () => { + build('mts') + expect(getDistFile('mts', 'mjs')).toContain('console.log(true)') + }) + it('loads vite.config.mts with package#type module', () => { + build('mts-module') + expect(getDistFile('mts-module', 'js')).toContain('console.log(true)') + }) + it('loads vite.config.cts', () => { + build('cts') + expect(getDistFile('cts', 'mjs')).toContain('console.log(true)') + }) + it('loads vite.config.cts with package#type module', () => { + build('cts-module') + expect(getDistFile('cts-module', 'js')).toContain('console.log(true)') + }) }) diff --git a/playground/resolve-config/__tests__/serve.ts b/playground/resolve-config/__tests__/serve.ts index d61ee70b7df50a..b2cc1ccc1e1e77 100644 --- a/playground/resolve-config/__tests__/serve.ts +++ b/playground/resolve-config/__tests__/serve.ts @@ -5,7 +5,7 @@ import path from 'node:path' import fs from 'fs-extra' import { isBuild, rootDir } from '~utils' -const configNames = ['js', 'cjs', 'mjs', 'ts'] +const configNames = ['js', 'cjs', 'mjs', 'ts', 'mts', 'cts'] export async function serve() { if (!isBuild) return @@ -18,9 +18,9 @@ export async function serve() { const pathToConf = fromTestDir(configName, `vite.config.${configName}`) await fs.copy(fromTestDir('root'), fromTestDir(configName)) - await fs.rename(fromTestDir(configName, 'vite.config.js'), pathToConf) + await fs.rename(fromTestDir(configName, 'vite.config.ts'), pathToConf) - if (configName === 'cjs') { + if (['cjs', 'cts'].includes(configName)) { const conf = await fs.readFile(pathToConf, 'utf8') await fs.writeFile( pathToConf, @@ -28,6 +28,12 @@ export async function serve() { ) } + // Remove TS annotation for plain JavaScript file. + if (configName.endsWith('js')) { + const conf = await fs.readFile(pathToConf, 'utf8') + await fs.writeFile(pathToConf, conf.replace(': boolean', '')) + } + // copy directory and add package.json with "type": "module" await fs.copy(fromTestDir(configName), fromTestDir(`${configName}-module`)) await fs.writeJSON(fromTestDir(`${configName}-module`, 'package.json'), { diff --git a/playground/resolve-config/root/vite.config.js b/playground/resolve-config/root/vite.config.ts similarity index 69% rename from playground/resolve-config/root/vite.config.js rename to playground/resolve-config/root/vite.config.ts index ed72046f940d59..a6ad03b2122361 100644 --- a/playground/resolve-config/root/vite.config.js +++ b/playground/resolve-config/root/vite.config.ts @@ -1,5 +1,6 @@ +const __CONFIG_LOADED__: boolean = true export default { - define: { __CONFIG_LOADED__: true }, + define: { __CONFIG_LOADED__ }, logLevel: 'silent', build: { minify: false, diff --git a/playground/vue-sourcemap/__tests__/__snapshots__/serve.spec.ts.snap b/playground/vue-sourcemap/__tests__/__snapshots__/serve.spec.ts.snap index 7a262ecd9a6f82..e91b6ce384c562 100644 --- a/playground/vue-sourcemap/__tests__/__snapshots__/serve.spec.ts.snap +++ b/playground/vue-sourcemap/__tests__/__snapshots__/serve.spec.ts.snap @@ -1,8 +1,149 @@ // Vitest Snapshot v1 +exports[`serve:vue-sourcemap > css 1`] = ` +{ + "mappings": ";AAQA;EACE,UAAU;AACZ", + "sources": [ + "/root/Css.vue", + ], + "sourcesContent": [ + " + + + + + + + + +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > css module 1`] = ` +{ + "mappings": ";AAcA;EACE,UAAU;AACZ", + "sources": [ + "/root/Css.vue", + ], + "sourcesContent": [ + " + + + + + + + + +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > css scoped 1`] = ` +{ + "mappings": ";AAoBA;EACE,UAAU;AACZ", + "sources": [ + "/root/Css.vue", + ], + "sourcesContent": [ + " + + + + + + + + +", + ], + "version": 3, +} +`; + exports[`serve:vue-sourcemap > js 1`] = ` { - "mappings": "mIAKA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;wBARlB,oBAAiB,WAAd,MAAU", + "mappings": "AAKA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;wBARlB,oBAAiB,WAAd,MAAU", "sources": [ "/root/Js.vue", ], @@ -23,3 +164,172 @@ console.log('setup') "version": 3, } `; + +exports[`serve:vue-sourcemap > less with additionalData 1`] = ` +{ + "mappings": "AAKA;EACE", + "sources": [ + "/root/Less.vue", + ], + "sourcesContent": [ + " + + +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > no script 1`] = ` +{ + "mappings": ";;;wBACE,oBAAwB,WAArB,aAAiB", + "sourceRoot": "", + "sources": [ + "/root/NoScript.vue", + ], + "sourcesContent": [ + " +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > no template 1`] = ` +{ + "mappings": "AACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;", + "sources": [ + "/root/NoTemplate.vue", + ], + "sourcesContent": [ + " + + +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > sass 1`] = ` +{ + "mappings": "AAKA;EACE", + "sources": [ + "/root/Sass.vue", + ], + "sourcesContent": [ + " + + +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > sass with import 1`] = ` +{ + "mappings": "AAAA;EACE;;ACOF;EACE", + "sources": [ + "/root/sassWithImportImported.sass", + "/root/SassWithImport.vue", + ], + "sourcesContent": [ + ".sass-with-import-imported + color: red +", + " + + +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > src imported 1`] = ` +{ + "mappings": "AAAA;EACE,UAAU;AACZ", + "sources": [ + "/root/src-import/src-import.css", + ], + "sourcesContent": [ + ".src-import { + color: red; +} +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > src imported sass 1`] = ` +{ + "mappings": "AAAA;EACE;;ACCF;EACE", + "sources": [ + "/root/src-import/src-import-imported.sass", + "/root/src-import/src-import.sass", + ], + "sourcesContent": [ + ".src-import-sass-imported + color: red +", + "@import './src-import-imported' + +.src-import-sass + color: red +", + ], + "version": 3, +} +`; + +exports[`serve:vue-sourcemap > ts 1`] = ` +{ + "mappings": ";AAKA,QAAQ,IAAI,WAAW;;;;;AAIvB,YAAQ,IAAI,UAAU;;;;;;;;uBARpB,oBAAiB,WAAd,MAAU", + "sources": [ + "/root/Ts.vue", + ], + "sourcesContent": [ + " + + + + +", + ], + "version": 3, +} +`; diff --git a/playground/vue-sourcemap/__tests__/serve.spec.ts b/playground/vue-sourcemap/__tests__/serve.spec.ts index e42a12e87be6a2..1ace0d7d1f4306 100644 --- a/playground/vue-sourcemap/__tests__/serve.spec.ts +++ b/playground/vue-sourcemap/__tests__/serve.spec.ts @@ -29,310 +29,55 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => { const res = await page.request.get(new URL('./Ts.vue', page.url()).href) const js = await res.text() const map = extractSourcemap(js) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": ";AAKA,QAAQ,IAAI,WAAW;;;;;AAIvB,YAAQ,IAAI,UAAU;;;;;;;;uBARpB,oBAAiB,WAAd,MAAU", - "sources": [ - "/root/Ts.vue", - ], - "sourcesContent": [ - " - - - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('css', async () => { const css = await getStyleTagContentIncluding('.css ') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": ";AAQA;EACE,UAAU;AACZ", - "sources": [ - "/root/Css.vue", - ], - "sourcesContent": [ - " - - - - - - - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('css module', async () => { const css = await getStyleTagContentIncluding('._css-module_') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": ";AAcA;EACE,UAAU;AACZ", - "sources": [ - "/root/Css.vue", - ], - "sourcesContent": [ - " - - - - - - - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('css scoped', async () => { const css = await getStyleTagContentIncluding('.css-scoped[data-v-') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": ";AAoBA;EACE,UAAU;AACZ", - "sources": [ - "/root/Css.vue", - ], - "sourcesContent": [ - " - - - - - - - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('sass', async () => { const css = await getStyleTagContentIncluding('.sass ') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": "AAKA;EACE", - "sources": [ - "/root/Sass.vue", - ], - "sourcesContent": [ - " - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('sass with import', async () => { const css = await getStyleTagContentIncluding('.sass-with-import ') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": "AAAA;EACE;;ACOF;EACE", - "sources": [ - "/root/sassWithImportImported.sass", - "/root/SassWithImport.vue", - ], - "sourcesContent": [ - ".sass-with-import-imported - color: red - ", - " - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('less with additionalData', async () => { const css = await getStyleTagContentIncluding('.less ') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": "AAKA;EACE", - "sources": [ - "/root/Less.vue", - ], - "sourcesContent": [ - " - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('src imported', async () => { const css = await getStyleTagContentIncluding('.src-import[data-v-') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": "AAAA;EACE,UAAU;AACZ", - "sources": [ - "/root/src-import/src-import.css", - ], - "sourcesContent": [ - ".src-import { - color: red; - } - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('src imported sass', async () => { const css = await getStyleTagContentIncluding('.src-import-sass[data-v-') const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": "AAAA;EACE;;ACCF;EACE", - "sources": [ - "/root/src-import/src-import-imported.sass", - "/root/src-import/src-import.sass", - ], - "sourcesContent": [ - ".src-import-sass-imported - color: red - ", - "@import './src-import-imported' - - .src-import-sass - color: red - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('no script', async () => { @@ -341,21 +86,7 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => { ) const js = await res.text() const map = extractSourcemap(js) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": ";;;wBACE", - "sources": [ - "/root/NoScript.vue", - ], - "sourcesContent": [ - " - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) test('no template', async () => { @@ -364,24 +95,6 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => { ) const js = await res.text() const map = extractSourcemap(js) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - { - "mappings": "2IACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC", - "sources": [ - "/root/NoTemplate.vue", - ], - "sourcesContent": [ - " - - - ", - ], - "version": 3, - } - `) + expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() }) }) diff --git a/playground/worker/__tests__/sourcemap/__snapshots__/sourcemap-worker.spec.ts.snap b/playground/worker/__tests__/sourcemap/__snapshots__/sourcemap-worker.spec.ts.snap deleted file mode 100644 index 3895aae40ad402..00000000000000 --- a/playground/worker/__tests__/sourcemap/__snapshots__/sourcemap-worker.spec.ts.snap +++ /dev/null @@ -1,14 +0,0 @@ -// Vitest Snapshot v1 - -exports[`serve:worker-sourcemap > nested worker 1`] = ` -{ - "mappings": "AAAA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,uCAAsB,CAAC;AAClD;AACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AACD;AACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B;AACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;", - "sources": [ - "/root/possible-ts-output-worker.mjs?worker_file", - ], - "sourcesContent": [ - null, - ], - "version": 3, -} -`; diff --git a/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts b/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts index 801369d8cb7271..a0ad8e7a355b8b 100644 --- a/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts +++ b/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts @@ -1,13 +1,6 @@ import fs from 'node:fs' import path from 'node:path' -import { - extractSourcemap, - formatSourcemapForSnapshot, - isBuild, - isServe, - page, - testDir -} from '~utils' +import { isBuild, testDir } from '~utils' describe.runIf(isBuild)('build', () => { // assert correct files @@ -120,16 +113,6 @@ describe.runIf(isBuild)('build', () => { }) }) -describe.runIf(isServe)('serve:worker-sourcemap', () => { - test('nested worker', async () => { - const res = await page.request.get( - new URL('./possible-ts-output-worker.mjs?worker_file', page.url()).href - ) - const map = extractSourcemap(await res.text()) - expect(formatSourcemapForSnapshot(map)).toMatchSnapshot() - }) -}) - function getSourceMapUrl(code: string): string { const regex = /\/\/[#@]\s(?:source(?:Mapping)?URL)=\s*(\S+)/g const results = regex.exec(code) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4a556b5478c221..b1b60a90616a11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,7 +42,6 @@ importers: eslint-define-config: ^1.5.1 eslint-plugin-import: ^2.26.0 eslint-plugin-node: ^11.1.0 - esno: ^0.16.3 execa: ^6.1.0 fs-extra: ^10.1.0 kill-port: ^1.6.1 @@ -61,6 +60,7 @@ importers: simple-git-hooks: ^2.8.0 sirv: ^2.0.2 tslib: ^2.4.0 + tsx: ^3.6.0 typescript: ^4.6.4 unbuild: ^0.7.4 vite: workspace:* @@ -100,7 +100,6 @@ importers: eslint-define-config: 1.5.1 eslint-plugin-import: 2.26.0_6lykrgsjl6r2vncmjcievjkgyy eslint-plugin-node: 11.1.0_eslint@8.18.0 - esno: 0.16.3 execa: 6.1.0 fs-extra: 10.1.0 kill-port: 1.6.1 @@ -119,6 +118,7 @@ importers: simple-git-hooks: 2.8.0 sirv: 2.0.2 tslib: 2.4.0 + tsx: 3.6.0 typescript: 4.6.4 unbuild: 0.7.4 vite: link:packages/vite @@ -216,7 +216,7 @@ importers: '@babel/types': ^7.18.4 '@jridgewell/trace-mapping': ^0.3.13 '@rollup/plugin-alias': ^3.1.9 - '@rollup/plugin-commonjs': ^21.1.0 + '@rollup/plugin-commonjs': ^22.0.1 '@rollup/plugin-dynamic-import-vars': ^1.4.3 '@rollup/plugin-json': ^4.1.0 '@rollup/plugin-node-resolve': 13.3.0 @@ -236,7 +236,6 @@ importers: dotenv-expand: ^5.1.0 es-module-lexer: ^0.10.5 esbuild: ^0.14.47 - esno: ^0.16.3 estree-walker: ^3.0.1 etag: ^1.8.1 fast-glob: ^3.2.11 @@ -284,7 +283,7 @@ importers: '@babel/types': 7.18.4 '@jridgewell/trace-mapping': 0.3.13 '@rollup/plugin-alias': 3.1.9_rollup@2.75.6 - '@rollup/plugin-commonjs': 21.1.0_rollup@2.75.6 + '@rollup/plugin-commonjs': 22.0.1_rollup@2.75.6 '@rollup/plugin-dynamic-import-vars': 1.4.3_rollup@2.75.6 '@rollup/plugin-json': 4.1.0_rollup@2.75.6 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.75.6 @@ -303,7 +302,6 @@ importers: dotenv: 14.3.2 dotenv-expand: 5.1.0 es-module-lexer: 0.10.5 - esno: 0.16.3 estree-walker: 3.0.1 etag: 1.8.1 fast-glob: 3.2.11 @@ -759,6 +757,17 @@ importers: devDependencies: '@vitejs/plugin-react': link:../../packages/plugin-react + playground/react-classic: + specifiers: + '@vitejs/plugin-react': workspace:* + react: ^18.1.0 + react-dom: ^18.1.0 + dependencies: + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + devDependencies: + '@vitejs/plugin-react': link:../../packages/plugin-react + playground/react-emotion: specifiers: '@babel/plugin-proposal-pipeline-operator': ^7.18.2 @@ -1761,25 +1770,25 @@ packages: resolution: {integrity: sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==} dev: false - /@esbuild-kit/cjs-loader/2.0.0: - resolution: {integrity: sha512-1ijCpmiCQcOcr0dmwwwCpzv0inWpNtEgiXDWc74AL52AhvY108M26suhWe9PMDcF1esnPJf0YSeVBLLZS6SQvg==} + /@esbuild-kit/cjs-loader/2.2.1: + resolution: {integrity: sha512-pq2Z4DcqTBF7y1wQuIzFVqmHJVnmP6hgHEWN2ubPjeG7OzXMZ9NvozW+YA/MIeMdZWp1jcJ/EvXk2+mfEKoCDQ==} dependencies: - '@esbuild-kit/core-utils': 1.1.1 - get-tsconfig: 3.0.1 + '@esbuild-kit/core-utils': 2.0.2 + get-tsconfig: 4.0.6 dev: true - /@esbuild-kit/core-utils/1.1.1: - resolution: {integrity: sha512-Y5QM1ip6nUvycH8dc/bfNPLNyVt2ccBLB09lAndUvfCza/UwkAfYSiNMbcAnkLcEciEENMm6Lsyt1L98K57v3w==} + /@esbuild-kit/core-utils/2.0.2: + resolution: {integrity: sha512-clNYQUsqtc36pzW5EufMsahcbLG45EaW3YDyf0DlaS0eCMkDXpxIlHwPC0rndUwG6Ytk9sMSD5k1qHbwYEC/OQ==} dependencies: - esbuild: 0.14.38 + esbuild: 0.14.47 + source-map-support: 0.5.21 dev: true - /@esbuild-kit/esm-loader/2.1.0: - resolution: {integrity: sha512-zE7BepoWvVhyoHDEnc2whD9x27UzdRIcUguOD6mUx8PzYjEw2pdNsY+2sP9PeGxW6YJvtLOqcDj3tqhxj61IPw==} + /@esbuild-kit/esm-loader/2.3.1: + resolution: {integrity: sha512-CC0H91Oa02cczLswEoiLowTzWxvnS3tIBGkQa1BnieFK7HHV4whrBFGRlUD9rMHfyyoO55IuOqNujycXX+gI8A==} dependencies: - '@esbuild-kit/core-utils': 1.1.1 - es-module-lexer: 0.10.5 - get-tsconfig: 3.0.1 + '@esbuild-kit/core-utils': 2.0.2 + get-tsconfig: 4.0.6 dev: true /@eslint/eslintrc/1.3.0: @@ -2010,6 +2019,22 @@ packages: rollup: 2.75.6 dev: true + /@rollup/plugin-commonjs/22.0.1_rollup@2.75.6: + resolution: {integrity: sha512-dGfEZvdjDHObBiP5IvwTKMVeq/tBZGMBHZFMdIV1ClMM/YoWS34xrHFGfag9SN2ZtMgNZRFruqvxZQEa70O6nQ==} + engines: {node: '>= 12.0.0'} + peerDependencies: + rollup: ^2.68.0 + dependencies: + '@rollup/pluginutils': 3.1.0_rollup@2.75.6 + commondir: 1.0.1 + estree-walker: 2.0.2 + glob: 7.2.0 + is-reference: 1.2.1 + magic-string: 0.25.9 + resolve: 1.22.1 + rollup: 2.75.6 + dev: true + /@rollup/plugin-dynamic-import-vars/1.4.3_rollup@2.75.6: resolution: {integrity: sha512-VYP9BBVI0pcYpLp/DkFT8YP+EmqmWFMmWXoTObDH6OouERxJyPsIj0tC3HxhjNBOKgcRc7eV75IQItzELt7QSg==} engines: {node: '>= 10.0.0'} @@ -2840,7 +2865,7 @@ packages: dev: true /asap/2.0.6: - resolution: {integrity: sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=} + resolution: {integrity: sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==} dev: true /asn1js/2.4.0: @@ -3245,7 +3270,7 @@ packages: dev: true /commondir/1.0.1: - resolution: {integrity: sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=} + resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} dev: true /compare-func/2.0.0: @@ -3312,7 +3337,7 @@ packages: dev: true /console-control-strings/1.1.0: - resolution: {integrity: sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=} + resolution: {integrity: sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==} dev: false /constantinople/4.0.1: @@ -3728,7 +3753,7 @@ packages: dev: false /delegates/1.0.0: - resolution: {integrity: sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=} + resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==} dev: false /denque/1.5.1: @@ -3945,15 +3970,6 @@ packages: ext: 1.6.0 dev: false - /esbuild-android-64/0.14.38: - resolution: {integrity: sha512-aRFxR3scRKkbmNuGAK+Gee3+yFxkTJO/cx83Dkyzo4CnQl/2zVSurtG6+G86EQIZ+w+VYngVyK7P3HyTBKu3nw==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - requiresBuild: true - dev: true - optional: true - /esbuild-android-64/0.14.47: resolution: {integrity: sha512-R13Bd9+tqLVFndncMHssZrPWe6/0Kpv2/dt4aA69soX4PRxlzsVpCvoJeFE8sOEoeVEiBkI0myjlkDodXlHa0g==} engines: {node: '>=12'} @@ -3970,15 +3986,6 @@ packages: dev: true optional: true - /esbuild-android-arm64/0.14.38: - resolution: {integrity: sha512-L2NgQRWuHFI89IIZIlpAcINy9FvBk6xFVZ7xGdOwIm8VyhX1vNCEqUJO3DPSSy945Gzdg98cxtNt8Grv1CsyhA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - /esbuild-android-arm64/0.14.47: resolution: {integrity: sha512-OkwOjj7ts4lBp/TL6hdd8HftIzOy/pdtbrNA4+0oVWgGG64HrdVzAF5gxtJufAPOsEjkyh1oIYvKAUinKKQRSQ==} engines: {node: '>=12'} @@ -3995,15 +4002,6 @@ packages: dev: true optional: true - /esbuild-darwin-64/0.14.38: - resolution: {integrity: sha512-5JJvgXkX87Pd1Og0u/NJuO7TSqAikAcQQ74gyJ87bqWRVeouky84ICoV4sN6VV53aTW+NE87qLdGY4QA2S7KNA==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /esbuild-darwin-64/0.14.47: resolution: {integrity: sha512-R6oaW0y5/u6Eccti/TS6c/2c1xYTb1izwK3gajJwi4vIfNs1s8B1dQzI1UiC9T61YovOQVuePDcfqHLT3mUZJA==} engines: {node: '>=12'} @@ -4020,15 +4018,6 @@ packages: dev: true optional: true - /esbuild-darwin-arm64/0.14.38: - resolution: {integrity: sha512-eqF+OejMI3mC5Dlo9Kdq/Ilbki9sQBw3QlHW3wjLmsLh+quNfHmGMp3Ly1eWm981iGBMdbtSS9+LRvR2T8B3eQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /esbuild-darwin-arm64/0.14.47: resolution: {integrity: sha512-seCmearlQyvdvM/noz1L9+qblC5vcBrhUaOoLEDDoLInF/VQ9IkobGiLlyTPYP5dW1YD4LXhtBgOyevoIHGGnw==} engines: {node: '>=12'} @@ -4045,15 +4034,6 @@ packages: dev: true optional: true - /esbuild-freebsd-64/0.14.38: - resolution: {integrity: sha512-epnPbhZUt93xV5cgeY36ZxPXDsQeO55DppzsIgWM8vgiG/Rz+qYDLmh5ts3e+Ln1wA9dQ+nZmVHw+RjaW3I5Ig==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - /esbuild-freebsd-64/0.14.47: resolution: {integrity: sha512-ZH8K2Q8/Ux5kXXvQMDsJcxvkIwut69KVrYQhza/ptkW50DC089bCVrJZZ3sKzIoOx+YPTrmsZvqeZERjyYrlvQ==} engines: {node: '>=12'} @@ -4070,15 +4050,6 @@ packages: dev: true optional: true - /esbuild-freebsd-arm64/0.14.38: - resolution: {integrity: sha512-/9icXUYJWherhk+y5fjPI5yNUdFPtXHQlwP7/K/zg8t8lQdHVj20SqU9/udQmeUo5pDFHMYzcEFfJqgOVeKNNQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - /esbuild-freebsd-arm64/0.14.47: resolution: {integrity: sha512-ZJMQAJQsIOhn3XTm7MPQfCzEu5b9STNC+s90zMWe2afy9EwnHV7Ov7ohEMv2lyWlc2pjqLW8QJnz2r0KZmeAEQ==} engines: {node: '>=12'} @@ -4095,15 +4066,6 @@ packages: dev: true optional: true - /esbuild-linux-32/0.14.38: - resolution: {integrity: sha512-QfgfeNHRFvr2XeHFzP8kOZVnal3QvST3A0cgq32ZrHjSMFTdgXhMhmWdKzRXP/PKcfv3e2OW9tT9PpcjNvaq6g==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-32/0.14.47: resolution: {integrity: sha512-FxZOCKoEDPRYvq300lsWCTv1kcHgiiZfNrPtEhFAiqD7QZaXrad8LxyJ8fXGcWzIFzRiYZVtB3ttvITBvAFhKw==} engines: {node: '>=12'} @@ -4120,15 +4082,6 @@ packages: dev: true optional: true - /esbuild-linux-64/0.14.38: - resolution: {integrity: sha512-uuZHNmqcs+Bj1qiW9k/HZU3FtIHmYiuxZ/6Aa+/KHb/pFKr7R3aVqvxlAudYI9Fw3St0VCPfv7QBpUITSmBR1Q==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-64/0.14.47: resolution: {integrity: sha512-nFNOk9vWVfvWYF9YNYksZptgQAdstnDCMtR6m42l5Wfugbzu11VpMCY9XrD4yFxvPo9zmzcoUL/88y0lfJZJJw==} engines: {node: '>=12'} @@ -4145,15 +4098,6 @@ packages: dev: true optional: true - /esbuild-linux-arm/0.14.38: - resolution: {integrity: sha512-FiFvQe8J3VKTDXG01JbvoVRXQ0x6UZwyrU4IaLBZeq39Bsbatd94Fuc3F1RGqPF5RbIWW7RvkVQjn79ejzysnA==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-arm/0.14.47: resolution: {integrity: sha512-ZGE1Bqg/gPRXrBpgpvH81tQHpiaGxa8c9Rx/XOylkIl2ypLuOcawXEAo8ls+5DFCcRGt/o3sV+PzpAFZobOsmA==} engines: {node: '>=12'} @@ -4170,15 +4114,6 @@ packages: dev: true optional: true - /esbuild-linux-arm64/0.14.38: - resolution: {integrity: sha512-HlMGZTEsBrXrivr64eZ/EO0NQM8H8DuSENRok9d+Jtvq8hOLzrxfsAT9U94K3KOGk2XgCmkaI2KD8hX7F97lvA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-arm64/0.14.47: resolution: {integrity: sha512-ywfme6HVrhWcevzmsufjd4iT3PxTfCX9HOdxA7Hd+/ZM23Y9nXeb+vG6AyA6jgq/JovkcqRHcL9XwRNpWG6XRw==} engines: {node: '>=12'} @@ -4195,15 +4130,6 @@ packages: dev: true optional: true - /esbuild-linux-mips64le/0.14.38: - resolution: {integrity: sha512-qd1dLf2v7QBiI5wwfil9j0HG/5YMFBAmMVmdeokbNAMbcg49p25t6IlJFXAeLzogv1AvgaXRXvgFNhScYEUXGQ==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-mips64le/0.14.47: resolution: {integrity: sha512-mg3D8YndZ1LvUiEdDYR3OsmeyAew4MA/dvaEJxvyygahWmpv1SlEEnhEZlhPokjsUMfRagzsEF/d/2XF+kTQGg==} engines: {node: '>=12'} @@ -4220,15 +4146,6 @@ packages: dev: true optional: true - /esbuild-linux-ppc64le/0.14.38: - resolution: {integrity: sha512-mnbEm7o69gTl60jSuK+nn+pRsRHGtDPfzhrqEUXyCl7CTOCLtWN2bhK8bgsdp6J/2NyS/wHBjs1x8aBWwP2X9Q==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-ppc64le/0.14.47: resolution: {integrity: sha512-WER+f3+szmnZiWoK6AsrTKGoJoErG2LlauSmk73LEZFQ/iWC+KhhDsOkn1xBUpzXWsxN9THmQFltLoaFEH8F8w==} engines: {node: '>=12'} @@ -4237,15 +4154,6 @@ packages: requiresBuild: true optional: true - /esbuild-linux-riscv64/0.14.38: - resolution: {integrity: sha512-+p6YKYbuV72uikChRk14FSyNJZ4WfYkffj6Af0/Tw63/6TJX6TnIKE+6D3xtEc7DeDth1fjUOEqm+ApKFXbbVQ==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-riscv64/0.14.47: resolution: {integrity: sha512-1fI6bP3A3rvI9BsaaXbMoaOjLE3lVkJtLxsgLHqlBhLlBVY7UqffWBvkrX/9zfPhhVMd9ZRFiaqXnB1T7BsL2g==} engines: {node: '>=12'} @@ -4254,15 +4162,6 @@ packages: requiresBuild: true optional: true - /esbuild-linux-s390x/0.14.38: - resolution: {integrity: sha512-0zUsiDkGJiMHxBQ7JDU8jbaanUY975CdOW1YDrurjrM0vWHfjv9tLQsW9GSyEb/heSK1L5gaweRjzfUVBFoybQ==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-s390x/0.14.47: resolution: {integrity: sha512-eZrWzy0xFAhki1CWRGnhsHVz7IlSKX6yT2tj2Eg8lhAwlRE5E96Hsb0M1mPSE1dHGpt1QVwwVivXIAacF/G6mw==} engines: {node: '>=12'} @@ -4279,15 +4178,6 @@ packages: dev: true optional: true - /esbuild-netbsd-64/0.14.38: - resolution: {integrity: sha512-cljBAApVwkpnJZfnRVThpRBGzCi+a+V9Ofb1fVkKhtrPLDYlHLrSYGtmnoTVWDQdU516qYI8+wOgcGZ4XIZh0Q==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: true - optional: true - /esbuild-netbsd-64/0.14.47: resolution: {integrity: sha512-Qjdjr+KQQVH5Q2Q1r6HBYswFTToPpss3gqCiSw2Fpq/ua8+eXSQyAMG+UvULPqXceOwpnPo4smyZyHdlkcPppQ==} engines: {node: '>=12'} @@ -4304,15 +4194,6 @@ packages: dev: true optional: true - /esbuild-openbsd-64/0.14.38: - resolution: {integrity: sha512-CDswYr2PWPGEPpLDUO50mL3WO/07EMjnZDNKpmaxUPsrW+kVM3LoAqr/CE8UbzugpEiflYqJsGPLirThRB18IQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: true - optional: true - /esbuild-openbsd-64/0.14.47: resolution: {integrity: sha512-QpgN8ofL7B9z8g5zZqJE+eFvD1LehRlxr25PBkjyyasakm4599iroUpaj96rdqRlO2ShuyqwJdr+oNqWwTUmQw==} engines: {node: '>=12'} @@ -4329,15 +4210,6 @@ packages: dev: true optional: true - /esbuild-sunos-64/0.14.38: - resolution: {integrity: sha512-2mfIoYW58gKcC3bck0j7lD3RZkqYA7MmujFYmSn9l6TiIcAMpuEvqksO+ntBgbLep/eyjpgdplF7b+4T9VJGOA==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: true - optional: true - /esbuild-sunos-64/0.14.47: resolution: {integrity: sha512-uOeSgLUwukLioAJOiGYm3kNl+1wJjgJA8R671GYgcPgCx7QR73zfvYqXFFcIO93/nBdIbt5hd8RItqbbf3HtAQ==} engines: {node: '>=12'} @@ -4354,15 +4226,6 @@ packages: dev: true optional: true - /esbuild-windows-32/0.14.38: - resolution: {integrity: sha512-L2BmEeFZATAvU+FJzJiRLFUP+d9RHN+QXpgaOrs2klshoAm1AE6Us4X6fS9k33Uy5SzScn2TpcgecbqJza1Hjw==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - /esbuild-windows-32/0.14.47: resolution: {integrity: sha512-H0fWsLTp2WBfKLBgwYT4OTfFly4Im/8B5f3ojDv1Kx//kiubVY0IQunP2Koc/fr/0wI7hj3IiBDbSrmKlrNgLQ==} engines: {node: '>=12'} @@ -4379,15 +4242,6 @@ packages: dev: true optional: true - /esbuild-windows-64/0.14.38: - resolution: {integrity: sha512-Khy4wVmebnzue8aeSXLC+6clo/hRYeNIm0DyikoEqX+3w3rcvrhzpoix0S+MF9vzh6JFskkIGD7Zx47ODJNyCw==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /esbuild-windows-64/0.14.47: resolution: {integrity: sha512-/Pk5jIEH34T68r8PweKRi77W49KwanZ8X6lr3vDAtOlH5EumPE4pBHqkCUdELanvsT14yMXLQ/C/8XPi1pAtkQ==} engines: {node: '>=12'} @@ -4404,15 +4258,6 @@ packages: dev: true optional: true - /esbuild-windows-arm64/0.14.38: - resolution: {integrity: sha512-k3FGCNmHBkqdJXuJszdWciAH77PukEyDsdIryEHn9cKLQFxzhT39dSumeTuggaQcXY57UlmLGIkklWZo2qzHpw==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /esbuild-windows-arm64/0.14.47: resolution: {integrity: sha512-HFSW2lnp62fl86/qPQlqw6asIwCnEsEoNIL1h2uVMgakddf+vUuMcCbtUY1i8sst7KkgHrVKCJQB33YhhOweCQ==} engines: {node: '>=12'} @@ -4445,34 +4290,6 @@ packages: esbuild-windows-arm64: 0.13.15 dev: true - /esbuild/0.14.38: - resolution: {integrity: sha512-12fzJ0fsm7gVZX1YQ1InkOE5f9Tl7cgf6JPYXRJtPIoE0zkWAbHdPHVPPaLi9tYAcEBqheGzqLn/3RdTOyBfcA==} - engines: {node: '>=12'} - hasBin: true - requiresBuild: true - optionalDependencies: - esbuild-android-64: 0.14.38 - esbuild-android-arm64: 0.14.38 - esbuild-darwin-64: 0.14.38 - esbuild-darwin-arm64: 0.14.38 - esbuild-freebsd-64: 0.14.38 - esbuild-freebsd-arm64: 0.14.38 - esbuild-linux-32: 0.14.38 - esbuild-linux-64: 0.14.38 - esbuild-linux-arm: 0.14.38 - esbuild-linux-arm64: 0.14.38 - esbuild-linux-mips64le: 0.14.38 - esbuild-linux-ppc64le: 0.14.38 - esbuild-linux-riscv64: 0.14.38 - esbuild-linux-s390x: 0.14.38 - esbuild-netbsd-64: 0.14.38 - esbuild-openbsd-64: 0.14.38 - esbuild-sunos-64: 0.14.38 - esbuild-windows-32: 0.14.38 - esbuild-windows-64: 0.14.38 - esbuild-windows-arm64: 0.14.38 - dev: true - /esbuild/0.14.47: resolution: {integrity: sha512-wI4ZiIfFxpkuxB8ju4MHrGwGLyp1+awEHAHVpx6w7a+1pmYIq8T9FGEVVwFo0iFierDoMj++Xq69GXWYn2EiwA==} engines: {node: '>=12'} @@ -4705,13 +4522,6 @@ packages: - supports-color dev: true - /esno/0.16.3: - resolution: {integrity: sha512-6slSBEV1lMKcX13DBifvnDFpNno5WXhw4j/ff7RI0y51BZiDqEe5dNhhjhIQ3iCOQuzsm2MbVzmwqbN78BBhPg==} - hasBin: true - dependencies: - tsx: 3.4.0 - dev: true - /espree/9.3.2: resolution: {integrity: sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -5115,8 +4925,8 @@ packages: resolution: {integrity: sha1-dKILqKSr7OWuGZrQPyvMaP38m6U=} dev: true - /get-tsconfig/3.0.1: - resolution: {integrity: sha512-+m30eQjbcf3xMNdnacXH5IDAKUMbI7Mhbf3e1BHif1FzBlUhBzBlmOVc7kL4+kB035l8OCyBdI3dNXZ3of9HqA==} + /get-tsconfig/4.0.6: + resolution: {integrity: sha512-yK9g+lk9PSaYS4RM9jnlmFSyymNDdLaIk42h6uOO6DOvqKEpL4KhUAcI1/7/sWe8+FWZe1/EjFXFfvv6T+cgPA==} dev: true /git-raw-commits/2.0.11: @@ -5259,7 +5069,7 @@ packages: dev: true /has-unicode/2.0.1: - resolution: {integrity: sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=} + resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==} dev: false /has/1.0.3: @@ -7540,7 +7350,7 @@ packages: dev: true /set-blocking/2.0.0: - resolution: {integrity: sha1-BF+XgtARrppoA93TgrJDkrPYkPc=} + resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} dev: false /setprototypeof/1.2.0: @@ -8101,7 +7911,7 @@ packages: dev: true /truncate-utf8-bytes/1.0.2: - resolution: {integrity: sha1-QFkjkJWS1W94pYGENLC3hInKXys=} + resolution: {integrity: sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ==} dependencies: utf8-byte-length: 1.0.4 dev: true @@ -8172,13 +7982,13 @@ packages: typescript: 4.6.4 dev: true - /tsx/3.4.0: - resolution: {integrity: sha512-WWakMoC5OqUXvOVZuyAySyETjAZ9rJxZXRbbOhYXDCeHF95hQUBa07UwUFu1yprlnrJ/W7XWfA99YTNKO//KxQ==} + /tsx/3.6.0: + resolution: {integrity: sha512-XzqSxPmyJnI7ZtEX/CLE/CSDkqbL7dK4jwtJRIZpV0EhCxWqtb1OqJPlUc4CVS3/MFdpt8ZxLpvPFohWRTHbzw==} hasBin: true dependencies: - '@esbuild-kit/cjs-loader': 2.0.0 - '@esbuild-kit/core-utils': 1.1.1 - '@esbuild-kit/esm-loader': 2.1.0 + '@esbuild-kit/cjs-loader': 2.2.1 + '@esbuild-kit/core-utils': 2.0.2 + '@esbuild-kit/esm-loader': 2.3.1 optionalDependencies: fsevents: 2.3.2 dev: true @@ -8356,7 +8166,7 @@ packages: dev: false /utf8-byte-length/1.0.4: - resolution: {integrity: sha1-9F8VDExm7uloGGUFq5P8u4rWv2E=} + resolution: {integrity: sha512-4+wkEYLBbWxqTahEsWrhxepcoVOJ+1z5PGIjPZxRkytcdSUaNjIjBM7Xn8E+pdSuV7SzvWovBFA54FO0JSoqhA==} dev: true /util-deprecate/1.0.2: @@ -8727,7 +8537,7 @@ packages: file:playground/external/dep-that-imports-vue: resolution: {directory: playground/external/dep-that-imports-vue, type: directory} name: '@vitejs/dep-that-imports-vue' - version: 0.0.1 + version: 0.0.0 dependencies: vue: 3.2.37 dev: false @@ -8735,7 +8545,7 @@ packages: file:playground/external/dep-that-requires-vue: resolution: {directory: playground/external/dep-that-requires-vue, type: directory} name: '@vitejs/dep-that-requires-vue' - version: 0.0.1 + version: 0.0.0 dependencies: vue: 3.2.37 dev: false