diff --git a/README.md b/README.md index 6fc1f49a80ee0f..db901f4af44917 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,11 @@ In addition, Vite is highly extensible via its [Plugin API](https://vitejs.dev/g ## Packages -| Package | Version (click for changelogs) | -| ------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- | -| [vite](packages/vite) | [![vite version](https://img.shields.io/npm/v/vite.svg?label=%20)](packages/vite/CHANGELOG.md) | -| [@vitejs/plugin-vue](packages/plugin-vue) | [![plugin-vue version](https://img.shields.io/npm/v/@vitejs/plugin-vue.svg?label=%20)](packages/plugin-vue/CHANGELOG.md) | -| [@vitejs/plugin-vue-jsx](packages/plugin-vue-jsx) | [![plugin-vue-jsx version](https://img.shields.io/npm/v/@vitejs/plugin-vue-jsx.svg?label=%20)](packages/plugin-vue-jsx/CHANGELOG.md) | -| [@vitejs/plugin-react](packages/plugin-react) | [![plugin-react version](https://img.shields.io/npm/v/@vitejs/plugin-react.svg?label=%20)](packages/plugin-react/CHANGELOG.md) | -| [@vitejs/plugin-legacy](packages/plugin-legacy) | [![plugin-legacy version](https://img.shields.io/npm/v/@vitejs/plugin-legacy.svg?label=%20)](packages/plugin-legacy/CHANGELOG.md) | -| [create-vite](packages/create-vite) | [![create-vite version](https://img.shields.io/npm/v/create-vite.svg?label=%20)](packages/create-vite/CHANGELOG.md) | +| Package | Version (click for changelogs) | +| ----------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- | +| [vite](packages/vite) | [![vite version](https://img.shields.io/npm/v/vite.svg?label=%20)](packages/vite/CHANGELOG.md) | +| [@vitejs/plugin-legacy](packages/plugin-legacy) | [![plugin-legacy version](https://img.shields.io/npm/v/@vitejs/plugin-legacy.svg?label=%20)](packages/plugin-legacy/CHANGELOG.md) | +| [create-vite](packages/create-vite) | [![create-vite version](https://img.shields.io/npm/v/create-vite.svg?label=%20)](packages/create-vite/CHANGELOG.md) | ## Contribution diff --git a/docs/blog/announcing-vite3.md b/docs/blog/announcing-vite3.md index 7f727f7307d767..1baf096d9ab6ac 100644 --- a/docs/blog/announcing-vite3.md +++ b/docs/blog/announcing-vite3.md @@ -239,7 +239,7 @@ While working towards Vite 3, we also improved the contributing experience for c - Vite upgraded to [pnpm 7](https://pnpm.io/), following the rest of the ecosystem. - Playgrounds have been moved to [`/playgrounds`](https://github.com/vitejs/vite/tree/main/playground) out of packages directory. - The packages and playgrounds are now `"type": "module"`. -- Plugins are now bundled using [unbuild](https://github.com/unjs/unbuild), and [plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) and [plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) were moved to TypeScript. +- Plugins are now bundled using [unbuild](https://github.com/unjs/unbuild), and [plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) and [plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) were moved to TypeScript. ## The Ecosystem is Ready for v3 diff --git a/docs/guide/features.md b/docs/guide/features.md index c90427247f820a..e0aeff3d9fb86b 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -22,7 +22,7 @@ Vite caches dependency requests via HTTP headers, so if you wish to locally edit ## Hot Module Replacement -Vite provides an [HMR API](./api-hmr) over native ESM. Frameworks with HMR capabilities can leverage the API to provide instant, precise updates without reloading the page or blowing away application state. Vite provides first-party HMR integrations for [Vue Single File Components](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) and [React Fast Refresh](https://github.com/vitejs/vite/tree/main/packages/plugin-react). There are also official integrations for Preact via [@prefresh/vite](https://github.com/JoviDeCroock/prefresh/tree/main/packages/vite). +Vite provides an [HMR API](./api-hmr) over native ESM. Frameworks with HMR capabilities can leverage the API to provide instant, precise updates without reloading the page or blowing away application state. Vite provides first-party HMR integrations for [Vue Single File Components](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) and [React Fast Refresh](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react). There are also official integrations for Preact via [@prefresh/vite](https://github.com/JoviDeCroock/prefresh/tree/main/packages/vite). Note you don't need to manually set these up - when you [create an app via `create-vite`](./), the selected templates would have these pre-configured for you already. @@ -120,8 +120,8 @@ declare module '*.svg' { Vite provides first-class Vue support: -- Vue 3 SFC support via [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) -- Vue 3 JSX support via [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) +- Vue 3 SFC support via [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) +- Vue 3 JSX support via [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) - Vue 2.7 support via [@vitejs/plugin-vue2](https://github.com/vitejs/vite-plugin-vue2) - Vue <2.7 support via [vite-plugin-vue2](https://github.com/underfin/vite-plugin-vue2) @@ -129,7 +129,7 @@ Vite provides first-class Vue support: `.jsx` and `.tsx` files are also supported out of the box. JSX transpilation is also handled via [esbuild](https://esbuild.github.io). -Vue users should use the official [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) plugin, which provides Vue 3 specific features including HMR, global component resolving, directives and slots. +Vue users should use the official [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) plugin, which provides Vue 3 specific features including HMR, global component resolving, directives and slots. If not using JSX with React or Vue, custom `jsxFactory` and `jsxFragment` can be configured using the [`esbuild` option](/config/shared-options.md#esbuild). For example for Preact: diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index 2761161216d4ce..0e50dcb2358dd5 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -18,8 +18,8 @@ If you have questions, the community is usually helpful at [Vite Discord's #ssr Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be used as references for this guide: -- [Vue 3](https://github.com/vitejs/vite/tree/main/playground/ssr-vue) -- [React](https://github.com/vitejs/vite/tree/main/playground/ssr-react) +- [Vue 3](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue) +- [React](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-react) ## Source Structure @@ -177,7 +177,7 @@ Then, in `server.js` we need to add some production specific logic by checking ` - Move the creation and all usage of the `vite` dev server behind dev-only conditional branches, then add static file serving middlewares to serve files from `dist/client`. -Refer to the [Vue](https://github.com/vitejs/vite/tree/main/playground/ssr-vue) and [React](https://github.com/vitejs/vite/tree/main/playground/ssr-react) demos for a working setup. +Refer to the [Vue](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue) and [React](https://github.com/vitejs/vite-plugin-react/tree/main/playground/ssr-react) demos for a working setup. ## Generating Preload Directives @@ -201,11 +201,11 @@ const html = await vueServerRenderer.renderToString(app, ctx) // ctx.modules is now a Set of module IDs that were used during the render ``` -In the production branch of `server.js` we need to read and pass the manifest to the `render` function exported by `src/entry-server.js`. This would provide us with enough information to render preload directives for files used by async routes! See [demo source](https://github.com/vitejs/vite/blob/main/playground/ssr-vue/src/entry-server.js) for a full example. +In the production branch of `server.js` we need to read and pass the manifest to the `render` function exported by `src/entry-server.js`. This would provide us with enough information to render preload directives for files used by async routes! See [demo source](https://github.com/vitejs/vite-plugin-vue/blob/main/playground/ssr-vue/src/entry-server.js) for a full example. ## Pre-Rendering / SSG -If the routes and the data needed for certain routes are known ahead of time, we can pre-render these routes into static HTML using the same logic as production SSR. This can also be considered a form of Static-Site Generation (SSG). See [demo pre-render script](https://github.com/vitejs/vite/blob/main/playground/ssr-vue/prerender.js) for working example. +If the routes and the data needed for certain routes are known ahead of time, we can pre-render these routes into static HTML using the same logic as production SSR. This can also be considered a form of Static-Site Generation (SSG). See [demo pre-render script](https://github.com/vitejs/vite-plugin-vue/blob/main/playground/ssr-vue/prerender.js) for working example. ## SSR Externals diff --git a/docs/plugins/index.md b/docs/plugins/index.md index 0a8803ba2d3b9a..a0057760319d8e 100644 --- a/docs/plugins/index.md +++ b/docs/plugins/index.md @@ -8,15 +8,15 @@ Check out [Using Plugins](../guide/using-plugins) for information on how to use ## Official Plugins -### [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) +### [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) - Provides Vue 3 Single File Components support. -### [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) +### [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) - Provides Vue 3 JSX support (via [dedicated Babel transform](https://github.com/vuejs/jsx-next)). -### [@vitejs/plugin-react](https://github.com/vitejs/vite/tree/main/packages/plugin-react) +### [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react) - Provides all-in-one React Support. diff --git a/package.json b/package.json index 1750cafe823860..91710cda3a3c80 100644 --- a/package.json +++ b/package.json @@ -114,8 +114,7 @@ "packageManager": "pnpm@7.17.1", "pnpm": { "overrides": { - "vite": "workspace:*", - "@vitejs/plugin-vue": "workspace:*" + "vite": "workspace:*" }, "packageExtensions": { "postcss-load-config": { diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index bcde3577f8f5b0..5bdd6ceae536b0 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -15,7 +15,7 @@ "devDependencies": { "@types/react": "^18.0.25", "@types/react-dom": "^18.0.9", - "@vitejs/plugin-react": "^2.2.0", + "@vitejs/plugin-react": "^3.0.0-alpha.0", "typescript": "^4.6.4", "vite": "^3.2.4" } diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index d33df374377dbe..985eea35a61b19 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -15,7 +15,7 @@ "devDependencies": { "@types/react": "^18.0.25", "@types/react-dom": "^18.0.9", - "@vitejs/plugin-react": "^2.2.0", + "@vitejs/plugin-react": "^3.0.0-alpha.0", "vite": "^3.2.4" } } diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index faf2538aa00766..349189f73c5378 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -12,7 +12,7 @@ "vue": "^3.2.45" }, "devDependencies": { - "@vitejs/plugin-vue": "^3.2.0", + "@vitejs/plugin-vue": "^4.0.0-alpha.0", "typescript": "^4.6.4", "vite": "^3.2.4", "vue-tsc": "^1.0.9" diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index 1b3046b597b244..f5afa5878d29e3 100644 --- a/packages/create-vite/template-vue/package.json +++ b/packages/create-vite/template-vue/package.json @@ -12,7 +12,7 @@ "vue": "^3.2.45" }, "devDependencies": { - "@vitejs/plugin-vue": "^3.2.0", + "@vitejs/plugin-vue": "^4.0.0-alpha.0", "vite": "^3.2.4" } } diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md deleted file mode 100644 index 16cb74e415f5f6..00000000000000 --- a/packages/plugin-react/CHANGELOG.md +++ /dev/null @@ -1,303 +0,0 @@ -## 3.0.0-alpha.2 (2022-11-30) - -* fix(deps): update all non-major dependencies (#11091) ([073a4bf](https://github.com/vitejs/vite/commit/073a4bf)), closes [#11091](https://github.com/vitejs/vite/issues/11091) - - - -## 3.0.0-alpha.1 (2022-11-15) - -* fix(plugin-react): jsxDev is not a function when is set NODE_ENV in env files (#10861) ([be1ba4a](https://github.com/vitejs/vite/commit/be1ba4a)), closes [#10861](https://github.com/vitejs/vite/issues/10861) -* perf: regexp perf issues, refactor regexp stylistic issues (#10905) ([fc007df](https://github.com/vitejs/vite/commit/fc007df)), closes [#10905](https://github.com/vitejs/vite/issues/10905) - - - -## 3.0.0-alpha.0 (2022-11-08) - -* feat!: transform jsx with esbuild instead of babel (#9590) ([f677b62](https://github.com/vitejs/vite/commit/f677b62)), closes [#9590](https://github.com/vitejs/vite/issues/9590) -* fix(deps): update all non-major dependencies (#10804) ([f686afa](https://github.com/vitejs/vite/commit/f686afa)), closes [#10804](https://github.com/vitejs/vite/issues/10804) - - - -## 2.2.0 (2022-10-26) - -* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) -* fix(plugin-react): update `package.json` (#10479) ([7f45eb5](https://github.com/vitejs/vite/commit/7f45eb5)), closes [#10479](https://github.com/vitejs/vite/issues/10479) -* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) - - - -## 2.2.0-beta.0 (2022-10-05) - -* fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) -* fix(deps): update all non-major dependencies (#10160) ([6233c83](https://github.com/vitejs/vite/commit/6233c83)), closes [#10160](https://github.com/vitejs/vite/issues/10160) -* fix(deps): update all non-major dependencies (#10316) ([a38b450](https://github.com/vitejs/vite/commit/a38b450)), closes [#10316](https://github.com/vitejs/vite/issues/10316) -* fix(deps): update all non-major dependencies (#9985) ([855f2f0](https://github.com/vitejs/vite/commit/855f2f0)), closes [#9985](https://github.com/vitejs/vite/issues/9985) -* fix(react): conditionally self-accept fast-refresh HMR (#10239) ([e976b06](https://github.com/vitejs/vite/commit/e976b06)), closes [#10239](https://github.com/vitejs/vite/issues/10239) -* feat: add `throwIfNamespace` option for custom JSX runtime (#9571) ([f842f74](https://github.com/vitejs/vite/commit/f842f74)), closes [#9571](https://github.com/vitejs/vite/issues/9571) -* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) - - - -## 2.1.0 (2022-09-05) - -* fix(plugin-react): duplicate __self prop and __source prop (#9387) ([c89de3a](https://github.com/vitejs/vite/commit/c89de3a)), closes [#9387](https://github.com/vitejs/vite/issues/9387) - - - -## 2.1.0-beta.0 (2022-08-29) - -* docs: fix typo (#9855) ([583f185](https://github.com/vitejs/vite/commit/583f185)), closes [#9855](https://github.com/vitejs/vite/issues/9855) -* fix: add `react` to `optimizeDeps` (#9056) ([bc4a627](https://github.com/vitejs/vite/commit/bc4a627)), closes [#9056](https://github.com/vitejs/vite/issues/9056) -* fix(deps): update all non-major dependencies (#9888) ([e35a58b](https://github.com/vitejs/vite/commit/e35a58b)), closes [#9888](https://github.com/vitejs/vite/issues/9888) - - - -## 2.0.1 (2022-08-11) - -* fix: don't count class declarations as react fast refresh boundry (fixes #3675) (#8887) ([5a18284](https://github.com/vitejs/vite/commit/5a18284)), closes [#3675](https://github.com/vitejs/vite/issues/3675) [#8887](https://github.com/vitejs/vite/issues/8887) -* fix: mention that Node.js 13/15 support is dropped (fixes #9113) (#9116) ([2826303](https://github.com/vitejs/vite/commit/2826303)), closes [#9113](https://github.com/vitejs/vite/issues/9113) [#9116](https://github.com/vitejs/vite/issues/9116) -* fix(deps): update all non-major dependencies (#9176) ([31d3b70](https://github.com/vitejs/vite/commit/31d3b70)), closes [#9176](https://github.com/vitejs/vite/issues/9176) -* fix(deps): update all non-major dependencies (#9575) ([8071325](https://github.com/vitejs/vite/commit/8071325)), closes [#9575](https://github.com/vitejs/vite/issues/9575) -* fix(plugin-react): wrong substitution causes `React is not defined` (#9386) ([8a5b575](https://github.com/vitejs/vite/commit/8a5b575)), closes [#9386](https://github.com/vitejs/vite/issues/9386) -* docs: fix server options link (#9242) ([29db3ea](https://github.com/vitejs/vite/commit/29db3ea)), closes [#9242](https://github.com/vitejs/vite/issues/9242) - - - -## 2.0.0 (2022-07-13) - -* chore: 3.0 release notes and bump peer deps (#9072) ([427ba26](https://github.com/vitejs/vite/commit/427ba26)), closes [#9072](https://github.com/vitejs/vite/issues/9072) -* fix(react): sourcemap incorrect warning and classic runtime sourcemap (#9006) ([bdae7fa](https://github.com/vitejs/vite/commit/bdae7fa)), closes [#9006](https://github.com/vitejs/vite/issues/9006) - - - -## 2.0.0-beta.1 (2022-07-06) - -* fix(deps): update all non-major dependencies (#8802) ([a4a634d](https://github.com/vitejs/vite/commit/a4a634d)), closes [#8802](https://github.com/vitejs/vite/issues/8802) -* fix(plugin-react): pass correct context to runPluginOverrides (#8809) ([09742e2](https://github.com/vitejs/vite/commit/09742e2)), closes [#8809](https://github.com/vitejs/vite/issues/8809) -* fix(plugin-react): return code if should skip in transform (fix #7586) (#8676) ([206e22a](https://github.com/vitejs/vite/commit/206e22a)), closes [#7586](https://github.com/vitejs/vite/issues/7586) [#8676](https://github.com/vitejs/vite/issues/8676) -* chore: use `tsx` directly instead of indirect `esno` (#8773) ([f018f13](https://github.com/vitejs/vite/commit/f018f13)), closes [#8773](https://github.com/vitejs/vite/issues/8773) - - - -## 2.0.0-beta.0 (2022-06-21) - -* feat: bump minimum node version to 14.18.0 (#8662) ([8a05432](https://github.com/vitejs/vite/commit/8a05432)), closes [#8662](https://github.com/vitejs/vite/issues/8662) -* feat: experimental.buildAdvancedBaseOptions (#8450) ([8ef7333](https://github.com/vitejs/vite/commit/8ef7333)), closes [#8450](https://github.com/vitejs/vite/issues/8450) -* feat: expose createFilter util (#8562) ([c5c424a](https://github.com/vitejs/vite/commit/c5c424a)), closes [#8562](https://github.com/vitejs/vite/issues/8562) -* chore: update major deps (#8572) ([0e20949](https://github.com/vitejs/vite/commit/0e20949)), closes [#8572](https://github.com/vitejs/vite/issues/8572) -* chore: use node prefix (#8309) ([60721ac](https://github.com/vitejs/vite/commit/60721ac)), closes [#8309](https://github.com/vitejs/vite/issues/8309) -* chore(deps): update all non-major dependencies (#8669) ([628863d](https://github.com/vitejs/vite/commit/628863d)), closes [#8669](https://github.com/vitejs/vite/issues/8669) -* fix(plugin-react): set `this-is-undefined-in-esm` to silent if classic runtime (#8674) ([f0aecba](https://github.com/vitejs/vite/commit/f0aecba)), closes [#8674](https://github.com/vitejs/vite/issues/8674) - - - -## 2.0.0-alpha.3 (2022-06-12) - -* fix(deps): update all non-major dependencies (#8391) ([842f995](https://github.com/vitejs/vite/commit/842f995)), closes [#8391](https://github.com/vitejs/vite/issues/8391) -* fix(plugin-react): apply manual runtime interop (#8546) ([f09299c](https://github.com/vitejs/vite/commit/f09299c)), closes [#8546](https://github.com/vitejs/vite/issues/8546) -* fix(plugin-react): support import namespace in `parseReactAlias` (#5313) ([05b91cd](https://github.com/vitejs/vite/commit/05b91cd)), closes [#5313](https://github.com/vitejs/vite/issues/5313) -* refactor: remove hooks ssr param support (#8491) ([f59adf8](https://github.com/vitejs/vite/commit/f59adf8)), closes [#8491](https://github.com/vitejs/vite/issues/8491) - - - -## 2.0.0-alpha.2 (2022-05-26) - -* feat: non-blocking esbuild optimization at build time (#8280) ([909cf9c](https://github.com/vitejs/vite/commit/909cf9c)), closes [#8280](https://github.com/vitejs/vite/issues/8280) -* feat(plugin-react): allow options.babel to be a function (#6238) ([f4d6262](https://github.com/vitejs/vite/commit/f4d6262)), closes [#6238](https://github.com/vitejs/vite/issues/6238) -* fix(deps): update all non-major dependencies (#8281) ([c68db4d](https://github.com/vitejs/vite/commit/c68db4d)), closes [#8281](https://github.com/vitejs/vite/issues/8281) -* fix(plugin-react): broken optimized deps dir check (#8255) ([9e2a1ea](https://github.com/vitejs/vite/commit/9e2a1ea)), closes [#8255](https://github.com/vitejs/vite/issues/8255) -* chore: use `esno` to replace `ts-node` (#8162) ([c18a5f3](https://github.com/vitejs/vite/commit/c18a5f3)), closes [#8162](https://github.com/vitejs/vite/issues/8162) - - - -## 2.0.0-alpha.1 (2022-05-19) - -* fix: rewrite CJS specific funcs/vars in plugins (#8227) ([9baa70b](https://github.com/vitejs/vite/commit/9baa70b)), closes [#8227](https://github.com/vitejs/vite/issues/8227) -* build!: bump targets (#8045) ([66efd69](https://github.com/vitejs/vite/commit/66efd69)), closes [#8045](https://github.com/vitejs/vite/issues/8045) -* chore: enable `import/no-duplicates` eslint rule (#8199) ([11243de](https://github.com/vitejs/vite/commit/11243de)), closes [#8199](https://github.com/vitejs/vite/issues/8199) - - - -## 2.0.0-alpha.0 (2022-05-13) - -* chore: restore-jsx.spec.ts lint (#8004) ([f1af941](https://github.com/vitejs/vite/commit/f1af941)), closes [#8004](https://github.com/vitejs/vite/issues/8004) -* chore: revert vitejs/vite#8152 (#8161) ([85b8b55](https://github.com/vitejs/vite/commit/85b8b55)), closes [vitejs/vite#8152](https://github.com/vitejs/vite/issues/8152) [#8161](https://github.com/vitejs/vite/issues/8161) -* chore: update plugins peer deps ([d57c23c](https://github.com/vitejs/vite/commit/d57c23c)) -* chore: use `unbuild` to bundle plugins (#8139) ([638b168](https://github.com/vitejs/vite/commit/638b168)), closes [#8139](https://github.com/vitejs/vite/issues/8139) -* chore(deps): use `esno` to replace `ts-node` (#8152) ([2363bd3](https://github.com/vitejs/vite/commit/2363bd3)), closes [#8152](https://github.com/vitejs/vite/issues/8152) -* chore(lint): sort for imports (#8113) ([43a58dd](https://github.com/vitejs/vite/commit/43a58dd)), closes [#8113](https://github.com/vitejs/vite/issues/8113) -* chore(plugin-react): add vite peer dep (#8083) ([2d978f7](https://github.com/vitejs/vite/commit/2d978f7)), closes [#8083](https://github.com/vitejs/vite/issues/8083) -* fix: use Vitest for unit testing, clean regex bug (#8040) ([63cd53d](https://github.com/vitejs/vite/commit/63cd53d)), closes [#8040](https://github.com/vitejs/vite/issues/8040) -* refactor: remove deprecated api for 3.0 (#5868) ([b5c3709](https://github.com/vitejs/vite/commit/b5c3709)), closes [#5868](https://github.com/vitejs/vite/issues/5868) -* build!: remove node v12 support (#7833) ([eeac2d2](https://github.com/vitejs/vite/commit/eeac2d2)), closes [#7833](https://github.com/vitejs/vite/issues/7833) - - - -## 1.3.2 (2022-05-02) - -* fix(plugin-react): React is not defined when component name is lowercase (#6838) ([bf40e5c](https://github.com/vitejs/vite/commit/bf40e5c)), closes [#6838](https://github.com/vitejs/vite/issues/6838) -* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) -* chore(deps): update all non-major dependencies (#7949) ([b877d30](https://github.com/vitejs/vite/commit/b877d30)), closes [#7949](https://github.com/vitejs/vite/issues/7949) - - - -## 1.3.1 (2022-04-13) - -* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) -* chore: fix term cases (#7553) ([c296130](https://github.com/vitejs/vite/commit/c296130)), closes [#7553](https://github.com/vitejs/vite/issues/7553) -* chore(deps): update all non-major dependencies (#7603) ([fc51a15](https://github.com/vitejs/vite/commit/fc51a15)), closes [#7603](https://github.com/vitejs/vite/issues/7603) - - - -## 1.3.0 (2022-03-30) - -* feat(plugin-react): adding jsxPure option (#7088) ([d451435](https://github.com/vitejs/vite/commit/d451435)), closes [#7088](https://github.com/vitejs/vite/issues/7088) -* fix(deps): update all non-major dependencies (#6782) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e)), closes [#6782](https://github.com/vitejs/vite/issues/6782) -* fix(deps): update all non-major dependencies (#7392) ([b63fc3b](https://github.com/vitejs/vite/commit/b63fc3b)), closes [#7392](https://github.com/vitejs/vite/issues/7392) -* chore: fix publish, build vite before plugin-react and plugin-vue (#6988) ([620a9bd](https://github.com/vitejs/vite/commit/620a9bd)), closes [#6988](https://github.com/vitejs/vite/issues/6988) -* chore(deps): update all non-major dependencies (#6905) ([839665c](https://github.com/vitejs/vite/commit/839665c)), closes [#6905](https://github.com/vitejs/vite/issues/6905) -* workflow: separate version bumping and publishing on release (#6879) ([fe8ef39](https://github.com/vitejs/vite/commit/fe8ef39)), closes [#6879](https://github.com/vitejs/vite/issues/6879) - - - -# [1.2.0](https://github.com/vitejs/vite/compare/plugin-react@1.1.4...plugin-react@1.2.0) (2022-02-09) - - -### Features - -* **plugin-react:** ensure `overrides` array exists before `api.reactBabel` hooks are called ([#6750](https://github.com/vitejs/vite/issues/6750)) ([104bdb5](https://github.com/vitejs/vite/commit/104bdb5b5e44e79bf3456cabe15f3753f7c1ef28)) - - - -## [1.1.4](https://github.com/vitejs/vite/compare/plugin-react@1.1.3...plugin-react@1.1.4) (2022-01-04) - - -### Bug Fixes - -* **plugin-react:** check for import React statement in .js files ([#6320](https://github.com/vitejs/vite/issues/6320)) ([bd9e97b](https://github.com/vitejs/vite/commit/bd9e97bd1b9156059b78b531871a12f6f47c04b1)), closes [#6148](https://github.com/vitejs/vite/issues/6148) [#6148](https://github.com/vitejs/vite/issues/6148) -* **plugin-react:** restore-jsx bug when component name is lowercase ([#6110](https://github.com/vitejs/vite/issues/6110)) ([ce65c56](https://github.com/vitejs/vite/commit/ce65c567a64fad3be4209cbd1132e62e905fe349)) - - -### Features - -* **plugin-react:** check for `api.reactBabel` on other plugins ([#5454](https://github.com/vitejs/vite/issues/5454)) ([2ab41b3](https://github.com/vitejs/vite/commit/2ab41b3184d2452be4fa0b427f05c791311644aa)) - - - -## [1.1.3](https://github.com/vitejs/vite/compare/plugin-react@1.1.2...plugin-react@1.1.3) (2021-12-13) - - -### Bug Fixes - -* **plugin-react:** only detect preamble in hmr context ([#6096](https://github.com/vitejs/vite/issues/6096)) ([8735294](https://github.com/vitejs/vite/commit/8735294055ce16308a6b8302eba4538f4a2931d0)) - - - -## [1.1.2](https://github.com/vitejs/vite/compare/plugin-react@1.1.1...plugin-react@1.1.2) (2021-12-13) - - -### Bug Fixes - -* ignore babel config when running restore-jsx ([#6047](https://github.com/vitejs/vite/issues/6047)) ([9c2843c](https://github.com/vitejs/vite/commit/9c2843cf0506844ee32f042a04c22c440434df2a)) - - - -## [1.1.1](https://github.com/vitejs/vite/compare/plugin-react@1.1.0...plugin-react@1.1.1) (2021-12-07) - - - -# [1.1.0](https://github.com/vitejs/vite/compare/plugin-react@1.1.0-beta.1...plugin-react@1.1.0) (2021-11-22) - - - -# [1.1.0-beta.1](https://github.com/vitejs/vite/compare/plugin-react@1.1.0-beta.0...plugin-react@1.1.0-beta.1) (2021-11-19) - - -### Bug Fixes - -* **plugin-react:** apply `babel.plugins` to project files only ([#5255](https://github.com/vitejs/vite/issues/5255)) ([377d0be](https://github.com/vitejs/vite/commit/377d0be5cf85a50240e160beaaafda77b7199452)) -* **plugin-react:** remove querystring from sourcemap filename ([#5760](https://github.com/vitejs/vite/issues/5760)) ([d93a9fa](https://github.com/vitejs/vite/commit/d93a9fab8986f3659e79d7b0b065e99ef625a5dd)) -* **plugin-react:** restore usage of extension instead of id ([#5761](https://github.com/vitejs/vite/issues/5761)) ([59471b1](https://github.com/vitejs/vite/commit/59471b186612d3da0083543e23d660747d3287f3)) -* **plugin-react:** uncompiled JSX in linked pkgs ([#5669](https://github.com/vitejs/vite/issues/5669)) ([41a7c9c](https://github.com/vitejs/vite/commit/41a7c9ccfbc1a7bc60aec672056eac3966ddd036)) - - - -# [1.1.0-beta.0](https://github.com/vitejs/vite/compare/plugin-react@1.0.6...plugin-react@1.1.0-beta.0) (2021-10-28) - - -### Bug Fixes - -* **plugin-react:** avoid mangling the sourcemaps of virtual modules ([#5421](https://github.com/vitejs/vite/issues/5421)) ([8556ffe](https://github.com/vitejs/vite/commit/8556ffe3c59952d7e64565422bf433699e97756e)) - - - -## [1.0.6](https://github.com/vitejs/vite/compare/plugin-react@1.0.5...plugin-react@1.0.6) (2021-10-25) - - -### Bug Fixes - -* **plugin-react:** account for querystring in transform hook ([#5333](https://github.com/vitejs/vite/issues/5333)) ([13c3813](https://github.com/vitejs/vite/commit/13c381368caf8302a0c5b7cec07dfc0eb344bede)) - - - -## [1.0.5](https://github.com/vitejs/vite/compare/plugin-react@1.0.4...plugin-react@1.0.5) (2021-10-18) - - -### Bug Fixes - -* **plugin-react:** fix regex for react imports ([#5274](https://github.com/vitejs/vite/issues/5274)) ([00b3e4f](https://github.com/vitejs/vite/commit/00b3e4fe102652b2d92e76a05e8c7a5b766b1d03)) -* **plugin-react:** transform .mjs files ([#5314](https://github.com/vitejs/vite/issues/5314)) ([8ce2ea1](https://github.com/vitejs/vite/commit/8ce2ea17d51b80c660f2cdca7844d4fc6991baed)) - - - -## [1.0.4](https://github.com/vitejs/vite/compare/plugin-react@1.0.3...plugin-react@1.0.4) (2021-10-11) - - - -## [1.0.3](https://github.com/vitejs/vite/compare/plugin-react@1.0.2...plugin-react@1.0.3) (2021-10-11) - - -### Bug Fixes - -* **plugin-react:** turn off jsx for .ts ([#5198](https://github.com/vitejs/vite/issues/5198)) ([916f9d3](https://github.com/vitejs/vite/commit/916f9d3984d5e83f7cb869b3606a1f043a814b97)), closes [#5102](https://github.com/vitejs/vite/issues/5102) - - - -## [1.0.2](https://github.com/vitejs/vite/compare/plugin-react@1.0.1...plugin-react@1.0.2) (2021-10-05) - - -### Bug Fixes - -* **plugin-react:** respect `opts.fastRefresh` in viteBabel ([#5139](https://github.com/vitejs/vite/issues/5139)) ([5cf4e69](https://github.com/vitejs/vite/commit/5cf4e69cd3afc7f960e02072171c7c441747e8f0)) - - - -## [1.0.1](https://github.com/vitejs/vite/compare/plugin-react@1.0.0...plugin-react@1.0.1) (2021-09-22) - - -### Bug Fixes - -* **plugin-react:** inconsistent error warning ([#5031](https://github.com/vitejs/vite/issues/5031)) ([89ba8ce](https://github.com/vitejs/vite/commit/89ba8cedb8636968516bc38b37e1d2d5ed6234bb)) - - -### Features - -* **plugin-react:** pre-optimize jsx-dev-runtime ([#5036](https://github.com/vitejs/vite/issues/5036)) ([a34dd27](https://github.com/vitejs/vite/commit/a34dd2725e64fedf626e23ba9ced480f5465a59b)) - - - -# [1.0.0](https://github.com/vitejs/vite/compare/plugin-react@1.0.0-beta.0...plugin-react@1.0.0) (2021-09-22) - -See the [readme](https://github.com/aleclarson/vite/blob/f8129ce6e87684eb7a4edd8106351c5d98207d7b/packages/plugin-react/README.md#vitejsplugin-react-) for more information. - -- Support for [automatic JSX runtime](https://github.com/alloc/vite-react-jsx) -- Babel integration for both development and production builds -- Add `react` and `react-dom` to [`resolve.dedupe`](https://vitejs.dev/config/#resolve-dedupe) automatically - -Thanks to @aleclarson and @pengx17 for preparing this release! - -# Legacy - -Before `@vitejs/plugin-react`, there was `@vitejs/plugin-react-refresh`. - -See its changelog [here.](https://github.com/vitejs/vite/blob/b9e837a2aa2c1a7a8f93d4b19df9f72fd3c6fb09/packages/plugin-react-refresh/CHANGELOG.md) diff --git a/packages/plugin-react/LICENSE b/packages/plugin-react/LICENSE deleted file mode 100644 index 9c1b313d7b1816..00000000000000 --- a/packages/plugin-react/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/plugin-react/README.md b/packages/plugin-react/README.md deleted file mode 100644 index 6a8f3cb0ac9e21..00000000000000 --- a/packages/plugin-react/README.md +++ /dev/null @@ -1,107 +0,0 @@ -# @vitejs/plugin-react [![npm](https://img.shields.io/npm/v/@vitejs/plugin-react.svg)](https://npmjs.com/package/@vitejs/plugin-react) - -The all-in-one Vite plugin for React projects. - -- enable [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development -- use the [automatic JSX runtime](https://github.com/alloc/vite-react-jsx#faq) -- avoid manual `import React` in `.jsx` and `.tsx` modules -- dedupe the `react` and `react-dom` packages -- use custom Babel plugins/presets - -```js -// vite.config.js -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' - -export default defineConfig({ - plugins: [react()] -}) -``` - -## Filter which files use Fast Refresh - -By default, Fast Refresh is used by files ending with `.js`, `.jsx`, `.ts`, and `.tsx`, except for files with a `node_modules` parent directory. - -In some situations, you may not want a file to act as a HMR boundary, instead preferring that the changes propagate higher in the stack before being handled. In these cases, you can provide an `include` and/or `exclude` option, which can be a regex, a [picomatch](https://github.com/micromatch/picomatch#globbing-features) pattern, or an array of either. Files matching `include` and not `exclude` will use Fast Refresh. The defaults are always applied. - -```js -react({ - // Exclude storybook stories - exclude: /\.stories\.(t|j)sx?$/, - // Only .tsx files - include: '**/*.tsx' -}) -``` - -## Opting out of the automatic JSX runtime - -By default, the plugin uses the [automatic JSX runtime](https://github.com/alloc/vite-react-jsx#faq). However, if you encounter any issues, you may opt out using the `jsxRuntime` option. - -```js -react({ - jsxRuntime: 'classic' -}) -``` - -## Babel configuration - -The `babel` option lets you add plugins, presets, and [other configuration](https://babeljs.io/docs/en/options) to the Babel transformation performed on each JSX/TSX file. - -```js -react({ - babel: { - presets: [...], - // Your plugins run before any built-in transform (eg: Fast Refresh) - plugins: [...], - // Use .babelrc files - babelrc: true, - // Use babel.config.js files - configFile: true, - } -}) -``` - -### Proposed syntax - -If you are using ES syntax that are still in proposal status (e.g. class properties), you can selectively enable them with the `babel.parserOpts.plugins` option: - -```js -react({ - babel: { - parserOpts: { - plugins: ['decorators-legacy'] - } - } -}) -``` - -This option does not enable _code transformation_. That is handled by esbuild. - -**Note:** TypeScript syntax is handled automatically. - -Here's the [complete list of Babel parser plugins](https://babeljs.io/docs/en/babel-parser#ecmascript-proposalshttpsgithubcombabelproposals). - -## Middleware mode - -In [middleware mode](https://vitejs.dev/config/server-options.html#server-middlewaremode), you should make sure your entry `index.html` file is transformed by Vite. Here's an example for an Express server: - -```js -app.get('/', async (req, res, next) => { - try { - let html = fs.readFileSync(path.resolve(root, 'index.html'), 'utf-8') - - // Transform HTML using Vite plugins. - html = await viteServer.transformIndexHtml(req.url, html) - - res.send(html) - } catch (e) { - return next(e) - } -}) -``` - -Otherwise, you'll probably get this error: - -``` -Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. -``` diff --git a/packages/plugin-react/build.config.ts b/packages/plugin-react/build.config.ts deleted file mode 100644 index 61165722c633a6..00000000000000 --- a/packages/plugin-react/build.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineBuildConfig } from 'unbuild' - -export default defineBuildConfig({ - entries: ['src/index'], - externals: ['vite'], - clean: true, - declaration: true, - rollup: { - emitCJS: true, - inlineDependencies: true - } -}) diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json deleted file mode 100644 index 67abbb1eff6d51..00000000000000 --- a/packages/plugin-react/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@vitejs/plugin-react", - "version": "3.0.0-alpha.2", - "license": "MIT", - "author": "Evan You", - "contributors": [ - "Alec Larson" - ], - "files": [ - "dist" - ], - "main": "./dist/index.cjs", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" - } - }, - "scripts": { - "dev": "unbuild --stub", - "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "tsx ../../scripts/patchCJS.ts", - "prepublishOnly": "npm run build" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vitejs/vite.git", - "directory": "packages/plugin-react" - }, - "bugs": { - "url": "https://github.com/vitejs/vite/issues" - }, - "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme", - "dependencies": { - "@babel/core": "^7.20.5", - "@babel/plugin-transform-react-jsx": "^7.19.0", - "@babel/plugin-transform-react-jsx-development": "^7.18.6", - "@babel/plugin-transform-react-jsx-self": "^7.18.6", - "@babel/plugin-transform-react-jsx-source": "^7.19.6", - "magic-string": "^0.26.7", - "react-refresh": "^0.14.0" - }, - "peerDependencies": { - "vite": "^3.0.0" - }, - "devDependencies": { - "vite": "workspace:*" - } -} diff --git a/packages/plugin-react/src/babel.d.ts b/packages/plugin-react/src/babel.d.ts deleted file mode 100644 index 2d13f794efb7a9..00000000000000 --- a/packages/plugin-react/src/babel.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '@babel/plugin-transform-react-jsx' -declare module '@babel/plugin-transform-react-jsx-self' -declare module '@babel/plugin-transform-react-jsx-source' -declare module 'react-refresh/babel.js' diff --git a/packages/plugin-react/src/fast-refresh.ts b/packages/plugin-react/src/fast-refresh.ts deleted file mode 100644 index 1461b4d785fe7b..00000000000000 --- a/packages/plugin-react/src/fast-refresh.ts +++ /dev/null @@ -1,155 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' -import { createRequire } from 'node:module' -import type { types as t } from '@babel/core' - -export const runtimePublicPath = '/@react-refresh' - -const _require = createRequire(import.meta.url) -const reactRefreshDir = path.dirname( - _require.resolve('react-refresh/package.json') -) -const runtimeFilePath = path.join( - reactRefreshDir, - 'cjs/react-refresh-runtime.development.js' -) - -export const runtimeCode = ` -const exports = {} -${fs.readFileSync(runtimeFilePath, 'utf-8')} -function debounce(fn, delay) { - let handle - return () => { - clearTimeout(handle) - handle = setTimeout(fn, delay) - } -} -exports.performReactRefresh = debounce(exports.performReactRefresh, 16) -export default exports -` - -export const preambleCode = ` -import RefreshRuntime from "__BASE__${runtimePublicPath.slice(1)}" -RefreshRuntime.injectIntoGlobalHook(window) -window.$RefreshReg$ = () => {} -window.$RefreshSig$ = () => (type) => type -window.__vite_plugin_react_preamble_installed__ = true -` - -const header = ` -import RefreshRuntime from "${runtimePublicPath}"; - -let prevRefreshReg; -let prevRefreshSig; - -if (import.meta.hot) { - if (!window.__vite_plugin_react_preamble_installed__) { - throw new Error( - "@vitejs/plugin-react can't detect preamble. Something is wrong. " + - "See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201" - ); - } - - prevRefreshReg = window.$RefreshReg$; - prevRefreshSig = window.$RefreshSig$; - window.$RefreshReg$ = (type, id) => { - RefreshRuntime.register(type, __SOURCE__ + " " + id) - }; - window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform; -}`.replace(/\n+/g, '') - -const timeout = ` - if (!window.__vite_plugin_react_timeout) { - window.__vite_plugin_react_timeout = setTimeout(() => { - window.__vite_plugin_react_timeout = 0; - RefreshRuntime.performReactRefresh(); - }, 30); - } -` - -const footer = ` -if (import.meta.hot) { - window.$RefreshReg$ = prevRefreshReg; - window.$RefreshSig$ = prevRefreshSig; - - __ACCEPT__ -}` - -const checkAndAccept = ` -function isReactRefreshBoundary(mod) { - if (mod == null || typeof mod !== 'object') { - return false; - } - let hasExports = false; - let areAllExportsComponents = true; - for (const exportName in mod) { - hasExports = true; - if (exportName === '__esModule') { - continue; - } - const desc = Object.getOwnPropertyDescriptor(mod, exportName); - if (desc && desc.get) { - // Don't invoke getters as they may have side effects. - return false; - } - const exportValue = mod[exportName]; - if (!RefreshRuntime.isLikelyComponentType(exportValue)) { - areAllExportsComponents = false; - } - } - return hasExports && areAllExportsComponents; -} - -import.meta.hot.accept(mod => { - if (isReactRefreshBoundary(mod)) { - ${timeout} - } else { - import.meta.hot.invalidate(); - } -}); -` - -export function addRefreshWrapper( - code: string, - id: string, - accept: boolean -): string { - return ( - header.replace('__SOURCE__', JSON.stringify(id)) + - code + - footer.replace('__ACCEPT__', accept ? checkAndAccept : timeout) - ) -} - -export function isRefreshBoundary(ast: t.File): boolean { - // Every export must be a potential React component. - // We'll also perform a runtime check that's more robust as well (isLikelyComponentType). - return ast.program.body.every((node) => { - if (node.type !== 'ExportNamedDeclaration') { - return true - } - const { declaration, specifiers } = node - if (declaration) { - if (declaration.type === 'ClassDeclaration') return false - if (declaration.type === 'VariableDeclaration') { - return declaration.declarations.every((variable) => - isComponentLikeIdentifier(variable.id) - ) - } - if (declaration.type === 'FunctionDeclaration') { - return !!declaration.id && isComponentLikeIdentifier(declaration.id) - } - } - return specifiers.every((spec) => { - return isComponentLikeIdentifier(spec.exported) - }) - }) -} - -function isComponentLikeIdentifier(node: t.Node): boolean { - return node.type === 'Identifier' && isComponentLikeName(node.name) -} - -function isComponentLikeName(name: string): boolean { - return typeof name === 'string' && name[0] >= 'A' && name[0] <= 'Z' -} diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts deleted file mode 100644 index f8aa1097cc037d..00000000000000 --- a/packages/plugin-react/src/index.ts +++ /dev/null @@ -1,464 +0,0 @@ -import path from 'node:path' -import type { ParserOptions, TransformOptions, types as t } from '@babel/core' -import * as babel from '@babel/core' -import { createFilter, loadEnv, normalizePath, resolveEnvPrefix } from 'vite' -import type { Plugin, PluginOption, ResolvedConfig } from 'vite' -import MagicString from 'magic-string' -import type { SourceMap } from 'magic-string' -import { - addRefreshWrapper, - isRefreshBoundary, - preambleCode, - runtimeCode, - runtimePublicPath -} from './fast-refresh' - -export interface Options { - include?: string | RegExp | Array - exclude?: string | RegExp | Array - /** - * Enable `react-refresh` integration. Vite disables this in prod env or build mode. - * @default true - */ - fastRefresh?: boolean - /** - * Set this to `"automatic"` to use [vite-react-jsx](https://github.com/alloc/vite-react-jsx). - * @default "automatic" - */ - jsxRuntime?: 'classic' | 'automatic' - /** - * Control where the JSX factory is imported from. - * This option is ignored when `jsxRuntime` is not `"automatic"`. - * @default "react" - */ - jsxImportSource?: string - /** - * Set this to `true` to annotate the JSX factory with `\/* @__PURE__ *\/`. - * This option is ignored when `jsxRuntime` is not `"automatic"`. - * @default true - */ - jsxPure?: boolean - /** - * Babel configuration applied in both dev and prod. - */ - babel?: - | BabelOptions - | ((id: string, options: { ssr?: boolean }) => BabelOptions) -} - -export type BabelOptions = Omit< - TransformOptions, - | 'ast' - | 'filename' - | 'root' - | 'sourceFileName' - | 'sourceMaps' - | 'inputSourceMap' -> - -/** - * The object type used by the `options` passed to plugins with - * an `api.reactBabel` method. - */ -export interface ReactBabelOptions extends BabelOptions { - plugins: Extract - presets: Extract - overrides: Extract - parserOpts: ParserOptions & { - plugins: Extract - } -} - -type ReactBabelHook = ( - babelConfig: ReactBabelOptions, - context: ReactBabelHookContext, - config: ResolvedConfig -) => void - -type ReactBabelHookContext = { ssr: boolean; id: string } - -declare module 'vite' { - export interface Plugin { - api?: { - /** - * Manipulate the Babel options of `@vitejs/plugin-react` - */ - reactBabel?: ReactBabelHook - } - } -} - -const prependReactImportCode = "import React from 'react'; " - -export default function viteReact(opts: Options = {}): PluginOption[] { - // Provide default values for Rollup compat. - let devBase = '/' - let filter = createFilter(opts.include, opts.exclude) - let needHiresSourcemap = false - let isProduction = true - let projectRoot = process.cwd() - let skipFastRefresh = opts.fastRefresh === false - let skipReactImport = false - let runPluginOverrides = ( - options: ReactBabelOptions, - context: ReactBabelHookContext - ) => false - let staticBabelOptions: ReactBabelOptions | undefined - - const useAutomaticRuntime = opts.jsxRuntime !== 'classic' - - // Support patterns like: - // - import * as React from 'react'; - // - import React from 'react'; - // - import React, {useEffect} from 'react'; - const importReactRE = /(?:^|\n)import\s+(?:\*\s+as\s+)?React(?:,|\s+)/ - - // Any extension, including compound ones like '.bs.js' - const fileExtensionRE = /\.[^/\s?]+$/ - - const viteBabel: Plugin = { - name: 'vite:react-babel', - enforce: 'pre', - config(userConfig, { mode }) { - // Copied from https://github.com/vitejs/vite/blob/4e9bdd4fb3654a9d43917e1cb682d3d2bad25115/packages/vite/src/node/config.ts#L477-L494 - - const resolvedRoot = normalizePath( - userConfig.root ? path.resolve(userConfig.root) : process.cwd() - ) - const envDir = userConfig.envDir - ? normalizePath(path.resolve(resolvedRoot, userConfig.envDir)) - : resolvedRoot - loadEnv(mode, envDir, resolveEnvPrefix(userConfig)) - - const isProduction = - (process.env.NODE_ENV || process.env.VITE_USER_NODE_ENV || mode) === - 'production' - - if (opts.jsxRuntime === 'classic') { - return { - esbuild: { - logOverride: { - 'this-is-undefined-in-esm': 'silent' - }, - jsx: 'transform', - jsxImportSource: opts.jsxImportSource, - jsxSideEffects: opts.jsxPure === false - } - } - } else { - return { - esbuild: { - jsxDev: !isProduction, - jsx: 'automatic', - jsxImportSource: opts.jsxImportSource, - jsxSideEffects: opts.jsxPure === false - } - } - } - }, - configResolved(config) { - devBase = config.base - projectRoot = config.root - filter = createFilter(opts.include, opts.exclude, { - resolve: projectRoot - }) - needHiresSourcemap = - config.command === 'build' && !!config.build.sourcemap - isProduction = config.isProduction - skipFastRefresh ||= isProduction || config.command === 'build' - - const jsxInject = config.esbuild && config.esbuild.jsxInject - if (jsxInject && importReactRE.test(jsxInject)) { - skipReactImport = true - config.logger.warn( - '[@vitejs/plugin-react] This plugin imports React for you automatically,' + - ' so you can stop using `esbuild.jsxInject` for that purpose.' - ) - } - - config.plugins.forEach((plugin) => { - const hasConflict = - plugin.name === 'react-refresh' || - (plugin !== viteReactJsx && plugin.name === 'vite:react-jsx') - - if (hasConflict) - return config.logger.warn( - `[@vitejs/plugin-react] You should stop using "${plugin.name}" ` + - `since this plugin conflicts with it.` - ) - }) - - runPluginOverrides = (babelOptions, context) => { - const hooks = config.plugins - .map((plugin) => plugin.api?.reactBabel) - .filter(Boolean) as ReactBabelHook[] - - if (hooks.length > 0) { - return (runPluginOverrides = (babelOptions, context) => { - hooks.forEach((hook) => hook(babelOptions, context, config)) - return true - })(babelOptions, context) - } - runPluginOverrides = () => false - return false - } - }, - async transform(code, id, options) { - const ssr = options?.ssr === true - // File extension could be mocked/overridden in querystring. - const [filepath, querystring = ''] = id.split('?') - const [extension = ''] = - querystring.match(fileExtensionRE) || - filepath.match(fileExtensionRE) || - [] - - if (/\.(?:mjs|[tj]sx?)$/.test(extension)) { - const isJSX = extension.endsWith('x') - const isNodeModules = id.includes('/node_modules/') - const isProjectFile = - !isNodeModules && (id[0] === '\0' || id.startsWith(projectRoot + '/')) - - let babelOptions = staticBabelOptions - if (typeof opts.babel === 'function') { - const rawOptions = opts.babel(id, { ssr }) - babelOptions = createBabelOptions(rawOptions) - runPluginOverrides(babelOptions, { ssr, id: id }) - } else if (!babelOptions) { - babelOptions = createBabelOptions(opts.babel) - if (!runPluginOverrides(babelOptions, { ssr, id: id })) { - staticBabelOptions = babelOptions - } - } - - const plugins = isProjectFile ? [...babelOptions.plugins] : [] - - let useFastRefresh = false - if (!skipFastRefresh && !ssr && !isNodeModules) { - // Modules with .js or .ts extension must import React. - const isReactModule = isJSX || importReactRE.test(code) - if (isReactModule && filter(id)) { - useFastRefresh = true - plugins.push([ - await loadPlugin('react-refresh/babel'), - { skipEnvCheck: true } - ]) - } - } - - let ast: t.File | null | undefined - let prependReactImport = false - if (!isProjectFile || isJSX) { - if (!useAutomaticRuntime && isProjectFile) { - // These plugins are only needed for the classic runtime. - if (!isProduction) { - plugins.push( - await loadPlugin('@babel/plugin-transform-react-jsx-self'), - await loadPlugin('@babel/plugin-transform-react-jsx-source') - ) - } - - // Even if the automatic JSX runtime is not used, we can still - // inject the React import for .jsx and .tsx modules. - if (!skipReactImport && !importReactRE.test(code)) { - prependReactImport = true - } - } - } - - let inputMap: SourceMap | undefined - if (prependReactImport) { - if (needHiresSourcemap) { - const s = new MagicString(code) - s.prepend(prependReactImportCode) - code = s.toString() - inputMap = s.generateMap({ hires: true, source: id }) - } else { - code = prependReactImportCode + code - } - } - - // Plugins defined through this Vite plugin are only applied - // to modules within the project root, but "babel.config.js" - // files can define plugins that need to be applied to every - // module, including node_modules and linked packages. - const shouldSkip = - !plugins.length && - !babelOptions.configFile && - !(isProjectFile && babelOptions.babelrc) - - // Avoid parsing if no plugins exist. - if (shouldSkip) { - return { - code, - map: inputMap ?? null - } - } - - const parserPlugins: typeof babelOptions.parserOpts.plugins = [ - ...babelOptions.parserOpts.plugins, - 'importMeta', - // This plugin is applied before esbuild transforms the code, - // so we need to enable some stage 3 syntax that is supported in - // TypeScript and some environments already. - 'topLevelAwait', - 'classProperties', - 'classPrivateProperties', - 'classPrivateMethods' - ] - - if (!extension.endsWith('.ts')) { - parserPlugins.push('jsx') - } - - if (/\.tsx?$/.test(extension)) { - parserPlugins.push('typescript') - } - - const transformAsync = ast - ? babel.transformFromAstAsync.bind(babel, ast, code) - : babel.transformAsync.bind(babel, code) - - const isReasonReact = extension.endsWith('.bs.js') - const result = await transformAsync({ - ...babelOptions, - ast: !isReasonReact, - root: projectRoot, - filename: id, - sourceFileName: filepath, - parserOpts: { - ...babelOptions.parserOpts, - sourceType: 'module', - allowAwaitOutsideFunction: true, - plugins: parserPlugins - }, - generatorOpts: { - ...babelOptions.generatorOpts, - decoratorsBeforeExport: true - }, - plugins, - sourceMaps: true, - // Vite handles sourcemap flattening - inputSourceMap: inputMap ?? (false as any) - }) - - if (result) { - let code = result.code! - if (useFastRefresh && /\$RefreshReg\$\(/.test(code)) { - const accept = isReasonReact || isRefreshBoundary(result.ast!) - code = addRefreshWrapper(code, id, accept) - } - return { - code, - map: result.map - } - } - } - } - } - - const viteReactRefresh: Plugin = { - name: 'vite:react-refresh', - enforce: 'pre', - config: () => ({ - resolve: { - dedupe: ['react', 'react-dom'] - } - }), - resolveId(id) { - if (id === runtimePublicPath) { - return id - } - }, - load(id) { - if (id === runtimePublicPath) { - return runtimeCode - } - }, - transformIndexHtml() { - if (!skipFastRefresh) - return [ - { - tag: 'script', - attrs: { type: 'module' }, - children: preambleCode.replace(`__BASE__`, devBase) - } - ] - } - } - - const reactJsxRuntimeId = 'react/jsx-runtime' - const reactJsxDevRuntimeId = 'react/jsx-dev-runtime' - const virtualReactJsxRuntimeId = '\0' + reactJsxRuntimeId - const virtualReactJsxDevRuntimeId = '\0' + reactJsxDevRuntimeId - // Adapted from https://github.com/alloc/vite-react-jsx - const viteReactJsx: Plugin = { - name: 'vite:react-jsx', - enforce: 'pre', - config() { - return { - optimizeDeps: { - // We can't add `react-dom` because the dependency is `react-dom/client` - // for React 18 while it's `react-dom` for React 17. We'd need to detect - // what React version the user has installed. - include: [reactJsxRuntimeId, reactJsxDevRuntimeId, 'react'] - } - } - }, - resolveId(id, importer) { - // Resolve runtime to a virtual path to be interoped. - // Since the interop code re-imports `id`, we need to prevent re-resolving - // to the virtual id if the importer is already the virtual id. - if (id === reactJsxRuntimeId && importer !== virtualReactJsxRuntimeId) { - return virtualReactJsxRuntimeId - } - if ( - id === reactJsxDevRuntimeId && - importer !== virtualReactJsxDevRuntimeId - ) { - return virtualReactJsxDevRuntimeId - } - }, - load(id) { - // Apply manual interop - if (id === virtualReactJsxRuntimeId) { - return [ - `import * as jsxRuntime from ${JSON.stringify(reactJsxRuntimeId)}`, - `export const Fragment = jsxRuntime.Fragment`, - `export const jsx = jsxRuntime.jsx`, - `export const jsxs = jsxRuntime.jsxs` - ].join('\n') - } - if (id === virtualReactJsxDevRuntimeId) { - return [ - `import * as jsxRuntime from ${JSON.stringify(reactJsxDevRuntimeId)}`, - `export const Fragment = jsxRuntime.Fragment`, - `export const jsxDEV = jsxRuntime.jsxDEV` - ].join('\n') - } - } - } - - return [viteBabel, viteReactRefresh, useAutomaticRuntime && viteReactJsx] -} - -viteReact.preambleCode = preambleCode - -function loadPlugin(path: string): Promise { - return import(path).then((module) => module.default || module) -} - -function createBabelOptions(rawOptions?: BabelOptions) { - const babelOptions = { - babelrc: false, - configFile: false, - ...rawOptions - } as ReactBabelOptions - - babelOptions.plugins ||= [] - babelOptions.presets ||= [] - babelOptions.overrides ||= [] - babelOptions.parserOpts ||= {} as any - babelOptions.parserOpts.plugins ||= [] - - return babelOptions -} diff --git a/packages/plugin-react/tsconfig.json b/packages/plugin-react/tsconfig.json deleted file mode 100644 index bd94458fe2dc28..00000000000000 --- a/packages/plugin-react/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "include": ["src"], - "exclude": ["**/*.spec.ts"], - "compilerOptions": { - "outDir": "dist", - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "Node", - "strict": true, - "declaration": true, - "sourceMap": true, - "noUnusedLocals": true, - "esModuleInterop": true, - "paths": { - "vite": ["../vite/src/node/index.js"] - } - } -} diff --git a/packages/plugin-vue-jsx/CHANGELOG.md b/packages/plugin-vue-jsx/CHANGELOG.md deleted file mode 100644 index 59b17beabb205d..00000000000000 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ /dev/null @@ -1,294 +0,0 @@ -## 3.0.0-alpha.0 (2022-11-30) - -* fix(deps): update all non-major dependencies (#10804) ([f686afa](https://github.com/vitejs/vite/commit/f686afa)), closes [#10804](https://github.com/vitejs/vite/issues/10804) -* fix(deps): update all non-major dependencies (#11091) ([073a4bf](https://github.com/vitejs/vite/commit/073a4bf)), closes [#11091](https://github.com/vitejs/vite/issues/11091) -* feat(plugin-vue-jsx): add `jsx` pure flag (#10205) ([333bacb](https://github.com/vitejs/vite/commit/333bacb)), closes [#10205](https://github.com/vitejs/vite/issues/10205) - - - -## 2.1.1 (2022-11-07) - -* chore(deps): update all non-major dependencies (#10725) ([22cfad8](https://github.com/vitejs/vite/commit/22cfad8)), closes [#10725](https://github.com/vitejs/vite/issues/10725) - - - -## 2.1.0 (2022-10-26) - -* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) - - - -## 2.1.0-beta.0 (2022-10-05) - -* fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) -* fix(deps): update all non-major dependencies (#10160) ([6233c83](https://github.com/vitejs/vite/commit/6233c83)), closes [#10160](https://github.com/vitejs/vite/issues/10160) -* fix(deps): update all non-major dependencies (#10316) ([a38b450](https://github.com/vitejs/vite/commit/a38b450)), closes [#10316](https://github.com/vitejs/vite/issues/10316) -* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) -* refactor(vue-jsx): remove `@babel/plugin-syntax-import-meta` (#10233) ([1bac86a](https://github.com/vitejs/vite/commit/1bac86a)), closes [#10233](https://github.com/vitejs/vite/issues/10233) - - - -## 2.0.1 (2022-08-29) - -* fix: mention that Node.js 13/15 support is dropped (fixes #9113) (#9116) ([2826303](https://github.com/vitejs/vite/commit/2826303)), closes [#9113](https://github.com/vitejs/vite/issues/9113) [#9116](https://github.com/vitejs/vite/issues/9116) -* fix(deps): update all non-major dependencies (#9176) ([31d3b70](https://github.com/vitejs/vite/commit/31d3b70)), closes [#9176](https://github.com/vitejs/vite/issues/9176) -* fix(deps): update all non-major dependencies (#9575) ([8071325](https://github.com/vitejs/vite/commit/8071325)), closes [#9575](https://github.com/vitejs/vite/issues/9575) -* fix(deps): update all non-major dependencies (#9888) ([e35a58b](https://github.com/vitejs/vite/commit/e35a58b)), closes [#9888](https://github.com/vitejs/vite/issues/9888) -* perf(plugin-vue-jsx): hoist variables (#9687) ([d9eb6b9](https://github.com/vitejs/vite/commit/d9eb6b9)), closes [#9687](https://github.com/vitejs/vite/issues/9687) - - - -## 2.0.0 (2022-07-13) - -* chore: 3.0 release notes and bump peer deps (#9072) ([427ba26](https://github.com/vitejs/vite/commit/427ba26)), closes [#9072](https://github.com/vitejs/vite/issues/9072) -* chore: use `tsx` directly instead of indirect `esno` (#8773) ([f018f13](https://github.com/vitejs/vite/commit/f018f13)), closes [#8773](https://github.com/vitejs/vite/issues/8773) -* chore(deps): update all non-major dependencies (#9022) ([6342140](https://github.com/vitejs/vite/commit/6342140)), closes [#9022](https://github.com/vitejs/vite/issues/9022) -* fix(deps): update all non-major dependencies (#8802) ([a4a634d](https://github.com/vitejs/vite/commit/a4a634d)), closes [#8802](https://github.com/vitejs/vite/issues/8802) - - - -## 2.0.0-beta.0 (2022-06-21) - -* chore: update major deps (#8572) ([0e20949](https://github.com/vitejs/vite/commit/0e20949)), closes [#8572](https://github.com/vitejs/vite/issues/8572) -* chore: use `esno` to replace `ts-node` (#8162) ([c18a5f3](https://github.com/vitejs/vite/commit/c18a5f3)), closes [#8162](https://github.com/vitejs/vite/issues/8162) -* chore: use node prefix (#8309) ([60721ac](https://github.com/vitejs/vite/commit/60721ac)), closes [#8309](https://github.com/vitejs/vite/issues/8309) -* feat: bump minimum node version to 14.18.0 (#8662) ([8a05432](https://github.com/vitejs/vite/commit/8a05432)), closes [#8662](https://github.com/vitejs/vite/issues/8662) -* feat: expose createFilter util (#8562) ([c5c424a](https://github.com/vitejs/vite/commit/c5c424a)), closes [#8562](https://github.com/vitejs/vite/issues/8562) -* refactor: remove hooks ssr param support (#8491) ([f59adf8](https://github.com/vitejs/vite/commit/f59adf8)), closes [#8491](https://github.com/vitejs/vite/issues/8491) -* docs(plugin-vue-jsx): update the options (#8496) ([0826f7b](https://github.com/vitejs/vite/commit/0826f7b)), closes [#8496](https://github.com/vitejs/vite/issues/8496) -* fix(deps): update all non-major dependencies (#8281) ([c68db4d](https://github.com/vitejs/vite/commit/c68db4d)), closes [#8281](https://github.com/vitejs/vite/issues/8281) -* fix(deps): update all non-major dependencies (#8391) ([842f995](https://github.com/vitejs/vite/commit/842f995)), closes [#8391](https://github.com/vitejs/vite/issues/8391) -* feat!: migrate to ESM (#8178) ([76fdc27](https://github.com/vitejs/vite/commit/76fdc27)), closes [#8178](https://github.com/vitejs/vite/issues/8178) - - - -## 2.0.0-alpha.1 (2022-05-19) - -* fix: rewrite CJS specific funcs/vars in plugins (#8227) ([9baa70b](https://github.com/vitejs/vite/commit/9baa70b)), closes [#8227](https://github.com/vitejs/vite/issues/8227) -* build!: bump targets (#8045) ([66efd69](https://github.com/vitejs/vite/commit/66efd69)), closes [#8045](https://github.com/vitejs/vite/issues/8045) - - - -## 2.0.0-alpha.0 (2022-05-13) - -* chore: revert vitejs/vite#8152 (#8161) ([85b8b55](https://github.com/vitejs/vite/commit/85b8b55)), closes [vitejs/vite#8152](https://github.com/vitejs/vite/issues/8152) [#8161](https://github.com/vitejs/vite/issues/8161) -* chore: update plugins peer deps ([d57c23c](https://github.com/vitejs/vite/commit/d57c23c)) -* chore: use `unbuild` to bundle plugins (#8139) ([638b168](https://github.com/vitejs/vite/commit/638b168)), closes [#8139](https://github.com/vitejs/vite/issues/8139) -* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) -* chore(deps): update all non-major dependencies (#7949) ([b877d30](https://github.com/vitejs/vite/commit/b877d30)), closes [#7949](https://github.com/vitejs/vite/issues/7949) -* chore(deps): use `esno` to replace `ts-node` (#8152) ([2363bd3](https://github.com/vitejs/vite/commit/2363bd3)), closes [#8152](https://github.com/vitejs/vite/issues/8152) -* chore(plugin-vue-jsx): add peer deps (#8086) ([7b48e22](https://github.com/vitejs/vite/commit/7b48e22)), closes [#8086](https://github.com/vitejs/vite/issues/8086) -* refactor: use node hash (#7975) ([5ce7c74](https://github.com/vitejs/vite/commit/5ce7c74)), closes [#7975](https://github.com/vitejs/vite/issues/7975) -* refactor: use optional chaining in config `define` of vue-jsx (#8046) ([9f8381e](https://github.com/vitejs/vite/commit/9f8381e)), closes [#8046](https://github.com/vitejs/vite/issues/8046) -* build!: remove node v12 support (#7833) ([eeac2d2](https://github.com/vitejs/vite/commit/eeac2d2)), closes [#7833](https://github.com/vitejs/vite/issues/7833) - - - -## 1.3.10 (2022-04-13) - -* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) - - - -## 1.3.9 (2022-03-30) - -* fix(deps): update all non-major dependencies (#7392) ([b63fc3b](https://github.com/vitejs/vite/commit/b63fc3b)), closes [#7392](https://github.com/vitejs/vite/issues/7392) -* chore(deps): update all non-major dependencies (#6905) ([839665c](https://github.com/vitejs/vite/commit/839665c)), closes [#6905](https://github.com/vitejs/vite/issues/6905) - - - -## [1.3.8](https://github.com/vitejs/vite/compare/plugin-vue@2.2.4...plugin-vue@1.3.8) (2022-02-28) - - - -## [1.3.7](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@1.3.7) (2022-02-14) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) - - - -## [1.3.6](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@1.3.6) (2022-02-12) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) - - - -## [1.3.5](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.4...plugin-vue-jsx@1.3.5) (2022-02-12) - - - -## [1.3.4](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.3...plugin-vue-jsx@1.3.4) (2022-02-09) - - - -## [1.3.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.2...plugin-vue-jsx@1.3.3) (2021-12-20) - - - -## [1.3.2](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.1...plugin-vue-jsx@1.3.2) (2021-12-13) - - -### Bug Fixes - -* allow overwriting `define` options in vue & vue-jsx plugins ([#6072](https://github.com/vitejs/vite/issues/6072)) ([5f3f6b7](https://github.com/vitejs/vite/commit/5f3f6b7b406cb3371084057c74814eb36175e5cf)) - - - -## [1.3.1](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.0...plugin-vue-jsx@1.3.1) (2021-12-07) - - - -# [1.3.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.0-beta.0...plugin-vue-jsx@1.3.0) (2021-11-22) - - - -# [1.3.0-beta.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.2.0...plugin-vue-jsx@1.3.0-beta.0) (2021-10-28) - - - -# [1.2.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.8...plugin-vue-jsx@1.2.0) (2021-09-29) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#4545](https://github.com/vitejs/vite/issues/4545)) ([a44fd5d](https://github.com/vitejs/vite/commit/a44fd5d38679da0be2536103e83af730cda73a95)) -* normalize internal plugin names ([#4976](https://github.com/vitejs/vite/issues/4976)) ([37f0b2f](https://github.com/vitejs/vite/commit/37f0b2fff74109d381513ed052a32b43655ee11d)) - - - -## [1.1.8](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.7...plugin-vue-jsx@1.1.8) (2021-09-07) - - -### Bug Fixes - -* hmr doesn't work when modifying the code of jsx in sfc ([#4563](https://github.com/vitejs/vite/issues/4563)) ([1012367](https://github.com/vitejs/vite/commit/101236794c5d6d28591302d5552cb1c0ab8f4115)) - - - -## [1.1.7](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.6...plugin-vue-jsx@1.1.7) (2021-07-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#4387](https://github.com/vitejs/vite/issues/4387)) ([2f900ba](https://github.com/vitejs/vite/commit/2f900ba4d4ad8061e0046898e8d1de3129e7f784)) - - - -## [1.1.6](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.5...plugin-vue-jsx@1.1.6) (2021-06-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#3791](https://github.com/vitejs/vite/issues/3791)) ([74d409e](https://github.com/vitejs/vite/commit/74d409eafca8d74ec4a6ece621ea2895bc1f2a32)) -* **plugin-vue-jsx:** replace default export with helper during SSR ([#3966](https://github.com/vitejs/vite/issues/3966)) ([bc86464](https://github.com/vitejs/vite/commit/bc86464d3c6591eae96e070a1724a3f21874c8ce)) -* **ssr:** normalize manifest filenames ([#3706](https://github.com/vitejs/vite/issues/3706)) ([aa8ca3f](https://github.com/vitejs/vite/commit/aa8ca3f35218c9fb48f87d3f6f4681d379ee45ca)), closes [#3303](https://github.com/vitejs/vite/issues/3303) - - -### Features - -* **plugin-vue-jsx:** jsx plugin should have extra babel plugins option ([#3923](https://github.com/vitejs/vite/issues/3923)) ([aada0c5](https://github.com/vitejs/vite/commit/aada0c5e71e4826cf049596f3459d48b386ea4da)) - - - -## [1.1.5](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.4...plugin-vue-jsx@1.1.5) (2021-06-01) - - -### Bug Fixes - -* include/exclude options for vue-jsx .d.ts ([#3573](https://github.com/vitejs/vite/issues/3573)) ([82ec0ca](https://github.com/vitejs/vite/commit/82ec0ca69c1f077cf518073edca4e6580ebd4892)) - - - -## [1.1.4](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.3...plugin-vue-jsx@1.1.4) (2021-05-03) - - -### Features - -* include/exclude options for vue-jsx plugin ([#1953](https://github.com/vitejs/vite/issues/1953)) ([fbecf1e](https://github.com/vitejs/vite/commit/fbecf1e5349ea5da8ff6f194efdcb152e2995398)) - - - -## [1.1.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.2...plugin-vue-jsx@1.1.3) (2021-03-31) - - -### Bug Fixes - -* ignore babelrc ([#2766](https://github.com/vitejs/vite/issues/2766)) ([23c4114](https://github.com/vitejs/vite/commit/23c41149ddf74261f7615d22e59b39a017b79509)), closes [#2722](https://github.com/vitejs/vite/issues/2722) - - - -## [1.1.2](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.1...plugin-vue-jsx@1.1.2) (2021-02-24) - - - -## [1.1.1](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.0...plugin-vue-jsx@1.1.1) (2021-02-24) - - -### Bug Fixes - -* **plugin-vue-jsx:** do not read babel configuration ([#2181](https://github.com/vitejs/vite/issues/2181)) ([8f0dc25](https://github.com/vitejs/vite/commit/8f0dc25e943ff490eefa0ed3663205a14e8eed9e)) - - - -# [1.1.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.3...plugin-vue-jsx@1.1.0) (2021-02-09) - - -### Features - -* **plugin-vue-jsx:** register jsx module during ssr ([7a6aa2a](https://github.com/vitejs/vite/commit/7a6aa2ad2689bf8221389924a608876866db7b0a)) - - - -## [1.0.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.2...plugin-vue-jsx@1.0.3) (2021-02-08) - - -### Bug Fixes - -* **plugin-vue-jsx:** support ssr ([30e92a1](https://github.com/vitejs/vite/commit/30e92a150e060e8bedcb6f0c477dcaa87e7996d6)), closes [#1939](https://github.com/vitejs/vite/issues/1939) - - - -## [1.0.2](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.1...plugin-vue-jsx@1.0.2) (2021-01-12) - - -### Bug Fixes - -* **plugin-vue-jsx:** files should include `index.d.ts` ([#1473](https://github.com/vitejs/vite/issues/1473)) [skip ci] ([f3ab497](https://github.com/vitejs/vite/commit/f3ab497b762e267721ace628bc6c7c5695b0d431)) -* **plugin-vue-jsx:** fix define call check ([#1480](https://github.com/vitejs/vite/issues/1480)) ([4ea065f](https://github.com/vitejs/vite/commit/4ea065f6278f30c022ed291bfb0412a674b18dd4)) -* **plugin-vue-jsx:** fix vue jsx hmr ([#1495](https://github.com/vitejs/vite/issues/1495)) ([6bdc3eb](https://github.com/vitejs/vite/commit/6bdc3eb2d004a28d2934946e33602f832b1ad8f2)) - - -### Performance Improvements - -* **plugin-vue-jsx:** only gen source map when necessary ([bfa8530](https://github.com/vitejs/vite/commit/bfa8530fc60deada634c38cfd6a23ab8ca05d47c)) - - - -## [1.0.1](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.0...plugin-vue-jsx@1.0.1) (2021-01-04) - - -### Bug Fixes - -* still let esbuild handle ts ([5903554](https://github.com/vitejs/vite/commit/59035546db7ff4b7020242ba994a5395aac92802)) - - - -# 2.0.0-beta.4 (2021-01-04) - - - -# 1.0.0 (2021-01-04) - - -### Features - -* vue-jsx support ([e756c48](https://github.com/vitejs/vite/commit/e756c48ed4c7372d4c8e26016ba4b91880e7e248)) - - - diff --git a/packages/plugin-vue-jsx/LICENSE b/packages/plugin-vue-jsx/LICENSE deleted file mode 100644 index 9c1b313d7b1816..00000000000000 --- a/packages/plugin-vue-jsx/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/plugin-vue-jsx/README.md b/packages/plugin-vue-jsx/README.md deleted file mode 100644 index c75e6d786f67b6..00000000000000 --- a/packages/plugin-vue-jsx/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# @vitejs/plugin-vue-jsx [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue-jsx.svg)](https://npmjs.com/package/@vitejs/plugin-vue-jsx) - -Provides Vue 3 JSX & TSX support with HMR. - -```js -// vite.config.js -import vueJsx from '@vitejs/plugin-vue-jsx' - -export default { - plugins: [ - vueJsx({ - // options are passed on to @vue/babel-plugin-jsx - }) - ] -} -``` - -## Options - -### include - -Type: `(string | RegExp)[] | string | RegExp | null` - -Default: `/\.[jt]sx$/` - -A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on. - -### exclude - -Type: `(string | RegExp)[] | string | RegExp | null` - -Default: `undefined` - -A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files to be ignored by the plugin. - -> See [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next) for other options. - -## HMR Detection - -This plugin supports HMR of Vue JSX components. The detection requirements are: - -- The component must be exported. -- The component must be declared by calling `defineComponent` via a root-level statement, either variable declaration or export declaration. - -### Supported patterns - -```jsx -import { defineComponent } from 'vue' - -// named exports w/ variable declaration: ok -export const Foo = defineComponent({}) - -// named exports referencing variable declaration: ok -const Bar = defineComponent({ render() { return
Test
}}) -export { Bar } - -// default export call: ok -export default defineComponent({ render() { return
Test
}}) - -// default export referencing variable declaration: ok -const Baz = defineComponent({ render() { return
Test
}}) -export default Baz -``` - -### Non-supported patterns - -```jsx -// not using `defineComponent` call -export const Bar = { ... } - -// not exported -const Foo = defineComponent(...) -``` diff --git a/packages/plugin-vue-jsx/build.config.ts b/packages/plugin-vue-jsx/build.config.ts deleted file mode 100644 index 6dcf1a5a2dc0b3..00000000000000 --- a/packages/plugin-vue-jsx/build.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineBuildConfig } from 'unbuild' - -export default defineBuildConfig({ - entries: ['src/index'], - clean: true, - declaration: true, - rollup: { - emitCJS: true - } -}) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json deleted file mode 100644 index cef092cb9fe2c5..00000000000000 --- a/packages/plugin-vue-jsx/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "@vitejs/plugin-vue-jsx", - "version": "3.0.0-alpha.0", - "license": "MIT", - "author": "Evan You", - "files": [ - "dist" - ], - "main": "./dist/index.cjs", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" - } - }, - "scripts": { - "dev": "unbuild --stub", - "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "tsx ../../scripts/patchCJS.ts", - "prepublishOnly": "npm run build" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vitejs/vite.git", - "directory": "packages/plugin-vue-jsx" - }, - "bugs": { - "url": "https://github.com/vitejs/vite/issues" - }, - "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx#readme", - "dependencies": { - "@babel/core": "^7.20.5", - "@babel/plugin-transform-typescript": "^7.20.2", - "@vue/babel-plugin-jsx": "^1.1.1" - }, - "devDependencies": { - "vite": "workspace:*" - }, - "peerDependencies": { - "vite": "^3.0.0", - "vue": "^3.0.0" - } -} diff --git a/packages/plugin-vue-jsx/src/index.ts b/packages/plugin-vue-jsx/src/index.ts deleted file mode 100644 index 15fcb808ed331b..00000000000000 --- a/packages/plugin-vue-jsx/src/index.ts +++ /dev/null @@ -1,283 +0,0 @@ -import { createHash } from 'node:crypto' -import path from 'node:path' -import type { types } from '@babel/core' -import * as babel from '@babel/core' -import jsx from '@vue/babel-plugin-jsx' -import { createFilter, normalizePath } from 'vite' -import type { ComponentOptions } from 'vue' -import type { Plugin } from 'vite' -// eslint-disable-next-line node/no-extraneous-import -import type { CallExpression, Identifier } from '@babel/types' -import type { Options } from './types' - -export * from './types' - -const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper' -const ssrRegisterHelperCode = - `import { useSSRContext } from "vue"\n` + - `export ${ssrRegisterHelper.toString()}` - -/** - * This function is serialized with toString() and evaluated as a virtual - * module during SSR - */ -function ssrRegisterHelper(comp: ComponentOptions, filename: string) { - const setup = comp.setup - comp.setup = (props, ctx) => { - // @ts-ignore - const ssrContext = useSSRContext() - ;(ssrContext.modules || (ssrContext.modules = new Set())).add(filename) - if (setup) { - return setup(props, ctx) - } - } -} - -function vueJsxPlugin(options: Options = {}): Plugin { - let root = '' - let needHmr = false - let needSourceMap = true - - const { include, exclude, babelPlugins = [], ...babelPluginOptions } = options - const filter = createFilter(include || /\.[jt]sx$/, exclude) - - return { - name: 'vite:vue-jsx', - - config(config) { - return { - // only apply esbuild to ts files - // since we are handling jsx and tsx now - esbuild: { - include: /\.ts$/ - }, - define: { - __VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true, - __VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false - } - } - }, - - configResolved(config) { - needHmr = config.command === 'serve' && !config.isProduction - needSourceMap = config.command === 'serve' || !!config.build.sourcemap - root = config.root - }, - - resolveId(id) { - if (id === ssrRegisterHelperId) { - return id - } - }, - - load(id) { - if (id === ssrRegisterHelperId) { - return ssrRegisterHelperCode - } - }, - - async transform(code, id, opt) { - const ssr = opt?.ssr === true - const [filepath] = id.split('?') - - // use id for script blocks in Vue SFCs (e.g. `App.vue?vue&type=script&lang.jsx`) - // use filepath for plain jsx files (e.g. App.jsx) - if (filter(id) || filter(filepath)) { - const plugins = [[jsx, babelPluginOptions], ...babelPlugins] - if (id.endsWith('.tsx') || filepath.endsWith('.tsx')) { - plugins.push([ - // @ts-ignore missing type - await import('@babel/plugin-transform-typescript').then( - (r) => r.default - ), - // @ts-ignore - { isTSX: true, allowExtensions: true } - ]) - } - - if (!ssr && !needHmr) { - plugins.push(() => { - return { - visitor: { - CallExpression: { - enter(_path: babel.NodePath) { - if (isDefineComponentCall(_path.node)) { - const callee = _path.node.callee as Identifier - callee.name = `/* @__PURE__ */ ${callee.name}` - } - } - } - } - } - }) - } - - const result = babel.transformSync(code, { - babelrc: false, - ast: true, - plugins, - sourceMaps: needSourceMap, - sourceFileName: id, - configFile: false - })! - - if (!ssr && !needHmr) { - if (!result.code) return - return { - code: result.code, - map: result.map - } - } - - interface HotComponent { - local: string - exported: string - id: string - } - - // check for hmr injection - const declaredComponents: { name: string }[] = [] - const hotComponents: HotComponent[] = [] - let hasDefault = false - - for (const node of result.ast!.program.body) { - if (node.type === 'VariableDeclaration') { - const names = parseComponentDecls(node, code) - if (names.length) { - declaredComponents.push(...names) - } - } - - if (node.type === 'ExportNamedDeclaration') { - if ( - node.declaration && - node.declaration.type === 'VariableDeclaration' - ) { - hotComponents.push( - ...parseComponentDecls(node.declaration, code).map( - ({ name }) => ({ - local: name, - exported: name, - id: getHash(id + name) - }) - ) - ) - } else if (node.specifiers.length) { - for (const spec of node.specifiers) { - if ( - spec.type === 'ExportSpecifier' && - spec.exported.type === 'Identifier' - ) { - const matched = declaredComponents.find( - ({ name }) => name === spec.local.name - ) - if (matched) { - hotComponents.push({ - local: spec.local.name, - exported: spec.exported.name, - id: getHash(id + spec.exported.name) - }) - } - } - } - } - } - - if (node.type === 'ExportDefaultDeclaration') { - if (node.declaration.type === 'Identifier') { - const _name = node.declaration.name - const matched = declaredComponents.find( - ({ name }) => name === _name - ) - if (matched) { - hotComponents.push({ - local: node.declaration.name, - exported: 'default', - id: getHash(id + 'default') - }) - } - } else if (isDefineComponentCall(node.declaration)) { - hasDefault = true - hotComponents.push({ - local: '__default__', - exported: 'default', - id: getHash(id + 'default') - }) - } - } - } - - if (hotComponents.length) { - if (hasDefault && (needHmr || ssr)) { - result.code = - result.code!.replace( - /export default defineComponent/g, - `const __default__ = defineComponent` - ) + `\nexport default __default__` - } - - if (needHmr && !ssr && !/\?vue&type=script/.test(id)) { - let code = result.code - let callbackCode = `` - for (const { local, exported, id } of hotComponents) { - code += - `\n${local}.__hmrId = "${id}"` + - `\n__VUE_HMR_RUNTIME__.createRecord("${id}", ${local})` - callbackCode += `\n__VUE_HMR_RUNTIME__.reload("${id}", __${exported})` - } - - code += `\nimport.meta.hot.accept(({${hotComponents - .map((c) => `${c.exported}: __${c.exported}`) - .join(',')}}) => {${callbackCode}\n})` - - result.code = code - } - - if (ssr) { - const normalizedId = normalizePath(path.relative(root, id)) - let ssrInjectCode = - `\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"` + - `\nconst __moduleId = ${JSON.stringify(normalizedId)}` - for (const { local } of hotComponents) { - ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)` - } - result.code += ssrInjectCode - } - } - - if (!result.code) return - return { - code: result.code, - map: result.map - } - } - } - } -} - -function parseComponentDecls(node: types.VariableDeclaration, source: string) { - const names = [] - for (const decl of node.declarations) { - if (decl.id.type === 'Identifier' && isDefineComponentCall(decl.init)) { - names.push({ - name: decl.id.name - }) - } - } - return names -} - -function isDefineComponentCall(node?: types.Node | null) { - return ( - node && - node.type === 'CallExpression' && - node.callee.type === 'Identifier' && - node.callee.name === 'defineComponent' - ) -} - -function getHash(text: string) { - return createHash('sha256').update(text).digest('hex').substring(0, 8) -} - -export default vueJsxPlugin diff --git a/packages/plugin-vue-jsx/src/types.ts b/packages/plugin-vue-jsx/src/types.ts deleted file mode 100644 index a3be580859ea00..00000000000000 --- a/packages/plugin-vue-jsx/src/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx' -import type { FilterPattern } from 'vite' - -export interface FilterOptions { - include?: FilterPattern - exclude?: FilterPattern -} - -export type Options = VueJSXPluginOptions & - FilterOptions & { babelPlugins?: any[] } diff --git a/packages/plugin-vue-jsx/tsconfig.json b/packages/plugin-vue-jsx/tsconfig.json deleted file mode 100644 index bd94458fe2dc28..00000000000000 --- a/packages/plugin-vue-jsx/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "include": ["src"], - "exclude": ["**/*.spec.ts"], - "compilerOptions": { - "outDir": "dist", - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "Node", - "strict": true, - "declaration": true, - "sourceMap": true, - "noUnusedLocals": true, - "esModuleInterop": true, - "paths": { - "vite": ["../vite/src/node/index.js"] - } - } -} diff --git a/packages/plugin-vue/CHANGELOG.md b/packages/plugin-vue/CHANGELOG.md deleted file mode 100644 index 41610f7205c41d..00000000000000 --- a/packages/plugin-vue/CHANGELOG.md +++ /dev/null @@ -1,630 +0,0 @@ -## 4.0.0-alpha.2 (2022-11-30) - -* docs(plugin-vue): update options in README (#11125) ([23d79b8](https://github.com/vitejs/vite/commit/23d79b8)), closes [#11125](https://github.com/vitejs/vite/issues/11125) -* fix(plugin-vue): invalidate script module cache when it changed in hot update (#11059) ([9d0b9d8](https://github.com/vitejs/vite/commit/9d0b9d8)), closes [#11059](https://github.com/vitejs/vite/issues/11059) -* fix(plugin-vue): support scss/sass/less... hmr on custom template languages (fix #10677) (#10844) ([d413848](https://github.com/vitejs/vite/commit/d413848)), closes [#10677](https://github.com/vitejs/vite/issues/10677) [#10844](https://github.com/vitejs/vite/issues/10844) - - - -## 4.0.0-alpha.1 (2022-11-22) - -* feat: dedupe the `vue` in client bundle by default (#11032) ([fae0e23](https://github.com/vitejs/vite/commit/fae0e23)), closes [#11032](https://github.com/vitejs/vite/issues/11032) - - - -## 4.0.0-alpha.0 (2022-11-15) - -* fix: handle HMR for Vue SFC with query parameters (fix #9341) (#10794) ([6462ab0](https://github.com/vitejs/vite/commit/6462ab0)), closes [#9341](https://github.com/vitejs/vite/issues/9341) [#10794](https://github.com/vitejs/vite/issues/10794) -* fix(vue): skip url query request (fixes #10863) (#10920) ([97d200c](https://github.com/vitejs/vite/commit/97d200c)), closes [#10863](https://github.com/vitejs/vite/issues/10863) [#10920](https://github.com/vitejs/vite/issues/10920) -* chore(deps): update all non-major dependencies (#10910) ([f6ad607](https://github.com/vitejs/vite/commit/f6ad607)), closes [#10910](https://github.com/vitejs/vite/issues/10910) -* chore(deps): update to rollup 3.3 (#10890) ([2d17aa2](https://github.com/vitejs/vite/commit/2d17aa2)), closes [#10890](https://github.com/vitejs/vite/issues/10890) -* perf: regexp perf issues, refactor regexp stylistic issues (#10905) ([fc007df](https://github.com/vitejs/vite/commit/fc007df)), closes [#10905](https://github.com/vitejs/vite/issues/10905) -* docs(plugin-vue): add link to plugin-vue-jsx (#10830) ([0c295e0](https://github.com/vitejs/vite/commit/0c295e0)), closes [#10830](https://github.com/vitejs/vite/issues/10830) -* feat: rollup 3 (#9870) ([beb7166](https://github.com/vitejs/vite/commit/beb7166)), closes [#9870](https://github.com/vitejs/vite/issues/9870) - - - -## 3.2.0 (2022-10-26) - -* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) -* chore(deps): update all non-major dependencies (#10488) ([15aa827](https://github.com/vitejs/vite/commit/15aa827)), closes [#10488](https://github.com/vitejs/vite/issues/10488) -* fix(plugin-vue): enable ts in template when using tsx in dev mode (#10180) ([a9f9d31](https://github.com/vitejs/vite/commit/a9f9d31)), closes [#10180](https://github.com/vitejs/vite/issues/10180) -* docs: add missing binding in asset import example (#10414) ([d7ac96d](https://github.com/vitejs/vite/commit/d7ac96d)), closes [#10414](https://github.com/vitejs/vite/issues/10414) - - - -## 3.2.0-beta.0 (2022-10-05) - -* fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) -* fix(deps): update all non-major dependencies (#10316) ([a38b450](https://github.com/vitejs/vite/commit/a38b450)), closes [#10316](https://github.com/vitejs/vite/issues/10316) -* fix(deps): update all non-major dependencies (#9985) ([855f2f0](https://github.com/vitejs/vite/commit/855f2f0)), closes [#9985](https://github.com/vitejs/vite/issues/9985) -* fix(deps): update rollup to `^2.79.1` (#10298) ([2266d83](https://github.com/vitejs/vite/commit/2266d83)), closes [#10298](https://github.com/vitejs/vite/issues/10298) -* fix(esbuild): transpile with esnext in dev (#10207) ([43b7b78](https://github.com/vitejs/vite/commit/43b7b78)), closes [#10207](https://github.com/vitejs/vite/issues/10207) -* chore(deps): update dependency slash to v5 (#10317) ([9d87c11](https://github.com/vitejs/vite/commit/9d87c11)), closes [#10317](https://github.com/vitejs/vite/issues/10317) -* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) - - - -## 3.1.0 (2022-09-05) - - - - -## 3.1.0-beta.0 (2022-08-29) - -* docs: fix typo (#9855) ([583f185](https://github.com/vitejs/vite/commit/583f185)), closes [#9855](https://github.com/vitejs/vite/issues/9855) -* feat: support object style hooks (#9634) ([757a92f](https://github.com/vitejs/vite/commit/757a92f)), closes [#9634](https://github.com/vitejs/vite/issues/9634) -* chore: fix typo (#9684) ([d30f881](https://github.com/vitejs/vite/commit/d30f881)), closes [#9684](https://github.com/vitejs/vite/issues/9684) -* chore(deps): update all non-major dependencies (#9675) ([4e56e87](https://github.com/vitejs/vite/commit/4e56e87)), closes [#9675](https://github.com/vitejs/vite/issues/9675) -* chore(plugin-vue): update reactivityTransform comment docs [ci skip] ([d04784b](https://github.com/vitejs/vite/commit/d04784b)) - - - -## 3.0.3 (2022-08-12) - - - - -## 3.0.2 (2022-08-11) - -* chore: fix code typos (#9033) ([ed02861](https://github.com/vitejs/vite/commit/ed02861)), closes [#9033](https://github.com/vitejs/vite/issues/9033) -* chore: narrow down rollup version (#9637) ([fcf4d98](https://github.com/vitejs/vite/commit/fcf4d98)), closes [#9637](https://github.com/vitejs/vite/issues/9637) - - - -## 3.0.1 (2022-07-18) - -* fix: mention that Node.js 13/15 support is dropped (fixes #9113) (#9116) ([2826303](https://github.com/vitejs/vite/commit/2826303)), closes [#9113](https://github.com/vitejs/vite/issues/9113) [#9116](https://github.com/vitejs/vite/issues/9116) -* fix(vue): remove ssr.external config (#9128) ([ec91f98](https://github.com/vitejs/vite/commit/ec91f98)), closes [#9128](https://github.com/vitejs/vite/issues/9128) -* refactor(vue): limit passable compilerOptions (#8994) ([b7b3e65](https://github.com/vitejs/vite/commit/b7b3e65)), closes [#8994](https://github.com/vitejs/vite/issues/8994) - - - -## 3.0.0 (2022-07-13) - -* chore: 3.0 release notes and bump peer deps (#9072) ([427ba26](https://github.com/vitejs/vite/commit/427ba26)), closes [#9072](https://github.com/vitejs/vite/issues/9072) -* fix(vue): handle undefined on import.meta.hot.accept (fixes #8625) (#9011) ([70af44a](https://github.com/vitejs/vite/commit/70af44a)), closes [#8625](https://github.com/vitejs/vite/issues/8625) [#9011](https://github.com/vitejs/vite/issues/9011) -* docs: cleanup changes (#8989) ([07aef1b](https://github.com/vitejs/vite/commit/07aef1b)), closes [#8989](https://github.com/vitejs/vite/issues/8989) - - - -## 3.0.0-beta.1 (2022-07-06) - -* fix(deps): update all non-major dependencies (#8802) ([a4a634d](https://github.com/vitejs/vite/commit/a4a634d)), closes [#8802](https://github.com/vitejs/vite/issues/8802) -* fix(plugin-vue): handle TS decorators in rewriteDefault fallback ([cb0c76a](https://github.com/vitejs/vite/commit/cb0c76a)) -* chore: use `tsx` directly instead of indirect `esno` (#8773) ([f018f13](https://github.com/vitejs/vite/commit/f018f13)), closes [#8773](https://github.com/vitejs/vite/issues/8773) -* chore(plugin-vue): mark export helper with null byte (#8792) ([8de4319](https://github.com/vitejs/vite/commit/8de4319)), closes [#8792](https://github.com/vitejs/vite/issues/8792) - - - -## 3.0.0-beta.0 (2022-06-21) - -* feat: bump minimum node version to 14.18.0 (#8662) ([8a05432](https://github.com/vitejs/vite/commit/8a05432)), closes [#8662](https://github.com/vitejs/vite/issues/8662) -* feat: experimental.buildAdvancedBaseOptions (#8450) ([8ef7333](https://github.com/vitejs/vite/commit/8ef7333)), closes [#8450](https://github.com/vitejs/vite/issues/8450) -* chore: use node prefix (#8309) ([60721ac](https://github.com/vitejs/vite/commit/60721ac)), closes [#8309](https://github.com/vitejs/vite/issues/8309) - - - -## 3.0.0-alpha.2 (2022-06-19) - -* fix(deps): update all non-major dependencies (#8281) ([c68db4d](https://github.com/vitejs/vite/commit/c68db4d)), closes [#8281](https://github.com/vitejs/vite/issues/8281) -* fix(deps): update all non-major dependencies (#8391) ([842f995](https://github.com/vitejs/vite/commit/842f995)), closes [#8391](https://github.com/vitejs/vite/issues/8391) -* fix(plugin-vue): fix sourcemap when no script block in sfc (close #8601) (#8604) ([ccfccec](https://github.com/vitejs/vite/commit/ccfccec)), closes [#8601](https://github.com/vitejs/vite/issues/8601) [#8604](https://github.com/vitejs/vite/issues/8604) -* chore: enable reportUnusedDisableDirectives (#8384) ([9a99bc4](https://github.com/vitejs/vite/commit/9a99bc4)), closes [#8384](https://github.com/vitejs/vite/issues/8384) -* chore: update major deps (#8572) ([0e20949](https://github.com/vitejs/vite/commit/0e20949)), closes [#8572](https://github.com/vitejs/vite/issues/8572) -* chore: use `esno` to replace `ts-node` (#8162) ([c18a5f3](https://github.com/vitejs/vite/commit/c18a5f3)), closes [#8162](https://github.com/vitejs/vite/issues/8162) -* chore(deps): update all non-major dependencies (#8474) ([6d0ede7](https://github.com/vitejs/vite/commit/6d0ede7)), closes [#8474](https://github.com/vitejs/vite/issues/8474) -* feat: expose createFilter util (#8562) ([c5c424a](https://github.com/vitejs/vite/commit/c5c424a)), closes [#8562](https://github.com/vitejs/vite/issues/8562) -* refactor: remove hooks ssr param support (#8491) ([f59adf8](https://github.com/vitejs/vite/commit/f59adf8)), closes [#8491](https://github.com/vitejs/vite/issues/8491) -* feat!: migrate to ESM (#8178) ([76fdc27](https://github.com/vitejs/vite/commit/76fdc27)), closes [#8178](https://github.com/vitejs/vite/issues/8178) - - - -## 3.0.0-alpha.1 (2022-05-19) - -* fix: rewrite CJS specific funcs/vars in plugins (#8227) ([9baa70b](https://github.com/vitejs/vite/commit/9baa70b)), closes [#8227](https://github.com/vitejs/vite/issues/8227) -* fix(plugin-vue): regenerate scoped css in build watch, fix #7980 (#7989) ([dc00225](https://github.com/vitejs/vite/commit/dc00225)), closes [#7980](https://github.com/vitejs/vite/issues/7980) [#7989](https://github.com/vitejs/vite/issues/7989) -* fix(plugin-vue): use server.origin when building base for transformAssetUrls (#8077) ([2f7a490](https://github.com/vitejs/vite/commit/2f7a490)), closes [#8077](https://github.com/vitejs/vite/issues/8077) -* build!: bump targets (#8045) ([66efd69](https://github.com/vitejs/vite/commit/66efd69)), closes [#8045](https://github.com/vitejs/vite/issues/8045) -* chore: enable `import/no-duplicates` eslint rule (#8199) ([11243de](https://github.com/vitejs/vite/commit/11243de)), closes [#8199](https://github.com/vitejs/vite/issues/8199) -* docs(plugin-vue): clarify asset url handling (#8184) ([32c75e2](https://github.com/vitejs/vite/commit/32c75e2)), closes [#8184](https://github.com/vitejs/vite/issues/8184) - - - -## 3.0.0-alpha.0 (2022-05-13) - -* chore: bump minors and rebuild lock (#8074) ([aeb5b74](https://github.com/vitejs/vite/commit/aeb5b74)), closes [#8074](https://github.com/vitejs/vite/issues/8074) -* chore: revert vitejs/vite#8152 (#8161) ([85b8b55](https://github.com/vitejs/vite/commit/85b8b55)), closes [vitejs/vite#8152](https://github.com/vitejs/vite/issues/8152) [#8161](https://github.com/vitejs/vite/issues/8161) -* chore: update plugins peer deps ([d57c23c](https://github.com/vitejs/vite/commit/d57c23c)) -* chore: upgrade to pnpm v7 (#8041) ([50f8f3b](https://github.com/vitejs/vite/commit/50f8f3b)), closes [#8041](https://github.com/vitejs/vite/issues/8041) -* chore: use `unbuild` to bundle plugins (#8139) ([638b168](https://github.com/vitejs/vite/commit/638b168)), closes [#8139](https://github.com/vitejs/vite/issues/8139) -* chore(deps): use `esno` to replace `ts-node` (#8152) ([2363bd3](https://github.com/vitejs/vite/commit/2363bd3)), closes [#8152](https://github.com/vitejs/vite/issues/8152) -* chore(lint): sort for imports (#8113) ([43a58dd](https://github.com/vitejs/vite/commit/43a58dd)), closes [#8113](https://github.com/vitejs/vite/issues/8113) -* chore(plugin-vue): change @rollup/pluginutils to dep from devDep (#8154) ([dcc8ea4](https://github.com/vitejs/vite/commit/dcc8ea4)), closes [#8154](https://github.com/vitejs/vite/issues/8154) -* chore(plugin-vue): replace source-map with gen/trace-mapping (#8155) ([79a8c85](https://github.com/vitejs/vite/commit/79a8c85)), closes [#8155](https://github.com/vitejs/vite/issues/8155) -* fix(plugin-vue): allow overwriting template.transformAssetUrls.includeAbsolute (fix #4836) (#6779) ([e0fe200](https://github.com/vitejs/vite/commit/e0fe200)), closes [#4836](https://github.com/vitejs/vite/issues/4836) [#6779](https://github.com/vitejs/vite/issues/6779) -* fix(plugin-vue): don't inline ts scripts during build (#7909) ([ba6cae9](https://github.com/vitejs/vite/commit/ba6cae9)), closes [#7909](https://github.com/vitejs/vite/issues/7909) -* fix(plugin-vue): trigger css hmr on custom template languages (#6987) ([2289d04](https://github.com/vitejs/vite/commit/2289d04)), closes [#6987](https://github.com/vitejs/vite/issues/6987) -* fix(plugin-vue): user defined transformAssetUrls ignored in production build (#7171) ([bfab569](https://github.com/vitejs/vite/commit/bfab569)), closes [#7171](https://github.com/vitejs/vite/issues/7171) -* fix(vue): same src file request same key (#8059) ([4c54800](https://github.com/vitejs/vite/commit/4c54800)), closes [#8059](https://github.com/vitejs/vite/issues/8059) -* refactor: use node hash (#7975) ([5ce7c74](https://github.com/vitejs/vite/commit/5ce7c74)), closes [#7975](https://github.com/vitejs/vite/issues/7975) -* build!: remove node v12 support (#7833) ([eeac2d2](https://github.com/vitejs/vite/commit/eeac2d2)), closes [#7833](https://github.com/vitejs/vite/issues/7833) - - - -## 2.3.2 (2022-05-04) - -* feat: import ts with .js in vue (#7998) ([9974094](https://github.com/vitejs/vite/commit/9974094)), closes [#7998](https://github.com/vitejs/vite/issues/7998) -* refactor(plugin-vue): remove querystring import (#7997) ([f3d15f1](https://github.com/vitejs/vite/commit/f3d15f1)), closes [#7997](https://github.com/vitejs/vite/issues/7997) -* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) - - - -## 2.3.1 (2022-03-30) - -* chore(plugin-vue): revert #7527, lower vite peer dep ([447bbeb](https://github.com/vitejs/vite/commit/447bbeb)), closes [#7527](https://github.com/vitejs/vite/issues/7527) - - - -## 2.3.0 (2022-03-30) - -* chore(plugin-vue): bump vite peer dep to 2.9.0 (#7472) ([12fd1d9](https://github.com/vitejs/vite/commit/12fd1d9)), closes [#7472](https://github.com/vitejs/vite/issues/7472) -* feat(css): css.devSourcemap option (#7471) ([57f14cb](https://github.com/vitejs/vite/commit/57f14cb)), closes [#7471](https://github.com/vitejs/vite/issues/7471) -* fix(plugin-vue): respect __VUE_PROD_DEVTOOLS__ setting (#4984) ([90e812a](https://github.com/vitejs/vite/commit/90e812a)), closes [#4984](https://github.com/vitejs/vite/issues/4984) - - - -## 2.3.0-beta.0 (2022-03-22) - -* fix(deps): update all non-major dependencies (#7392) ([b63fc3b](https://github.com/vitejs/vite/commit/b63fc3b)), closes [#7392](https://github.com/vitejs/vite/issues/7392) -* feat: css sourcemap support during dev (#7173) ([38a655f](https://github.com/vitejs/vite/commit/38a655f)), closes [#7173](https://github.com/vitejs/vite/issues/7173) -* chore(deps): update all non-major dependencies (#6905) ([839665c](https://github.com/vitejs/vite/commit/839665c)), closes [#6905](https://github.com/vitejs/vite/issues/6905) -* docs(vue): add transformAssetUrls example (#7232) ([08e928c](https://github.com/vitejs/vite/commit/08e928c)), closes [#7232](https://github.com/vitejs/vite/issues/7232) - - - -## [2.2.4](https://github.com/vitejs/vite/compare/plugin-vue@2.2.3...plugin-vue@2.2.4) (2022-02-28) - - - -## [2.2.3](https://github.com/vitejs/vite/compare/plugin-vue@2.2.2...plugin-vue@2.2.3) (2022-02-28) - - -### Bug Fixes - -* **plugin-vue:** setup jsx script no hmr ([#6568](https://github.com/vitejs/vite/issues/6568)) ([c84601c](https://github.com/vitejs/vite/commit/c84601cee5232bad0f65c8fcc663e38bb457a0b3)) - - - -## [2.2.2](https://github.com/vitejs/vite/compare/plugin-vue@2.2.1...plugin-vue@2.2.2) (2022-02-18) - - - -## [2.2.1](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@2.2.1) (2022-02-18) - - -### Bug Fixes - -* adjust vue template sourcemap ([#6972](https://github.com/vitejs/vite/issues/6972)) ([a774303](https://github.com/vitejs/vite/commit/a7743039f263f41e1c3971e324f893a5ef5e5508)) -* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) - - - -# [2.2.0](https://github.com/vitejs/vite/compare/plugin-vue@2.1.0...plugin-vue@2.2.0) (2022-02-09) - - -### Bug Fixes - -* plugin-vue `options.compiler` field ([#6588](https://github.com/vitejs/vite/issues/6588)) ([caec019](https://github.com/vitejs/vite/commit/caec01998a9599d255761f3efc1c49827aadac0d)), closes [#6587](https://github.com/vitejs/vite/issues/6587) - - - -# [2.1.0](https://github.com/vitejs/vite/compare/plugin-vue@2.0.1...plugin-vue@2.1.0) (2022-01-21) - - -### Bug Fixes - -* **plugin-vue:** compiler is null on rollup ([#6566](https://github.com/vitejs/vite/issues/6566)) ([b289b2d](https://github.com/vitejs/vite/commit/b289b2d433f94949730e1f041f3c8e16c417e9d0)) -* **plugin-vue:** make cssm code tree shakeable ([#6353](https://github.com/vitejs/vite/issues/6353)) ([3fb4118](https://github.com/vitejs/vite/commit/3fb4118026e2745140894afb9755298656750f43)) -* update the vue version in the error message ([#6252](https://github.com/vitejs/vite/issues/6252)) ([6a47083](https://github.com/vitejs/vite/commit/6a47083df14cb8d2584a86abda8a5e89a731c170)) - - - -## [2.0.1](https://github.com/vitejs/vite/compare/plugin-vue@2.0.0...plugin-vue@2.0.1) (2021-12-14) - - -### Bug Fixes - -* **plugin-vue:** error.length is zero ([#6106](https://github.com/vitejs/vite/issues/6106)) ([5ec49be](https://github.com/vitejs/vite/commit/5ec49befad4d7b5e7cc14f14520ba96d5b6f6d69)) - - - -# [2.0.0](https://github.com/vitejs/vite/compare/plugin-vue@1.10.2...plugin-vue@2.0.0) (2021-12-12) - - -### Bug Fixes - -* allow overwriting `define` options in vue & vue-jsx plugins ([#6072](https://github.com/vitejs/vite/issues/6072)) ([5f3f6b7](https://github.com/vitejs/vite/commit/5f3f6b7b406cb3371084057c74814eb36175e5cf)) -* **plugin-vue:** multiple vue files using the same src file (fix [#5925](https://github.com/vitejs/vite/issues/5925), [#5447](https://github.com/vitejs/vite/issues/5447)) ([#5994](https://github.com/vitejs/vite/issues/5994)) ([df7aec7](https://github.com/vitejs/vite/commit/df7aec7d2a567af1dfbab76e5765aba80dc3cb5c)) - - -### Code Refactoring - -* **plugin-vue:** resolve vue/compiler-sfc from project root ([ce8b0fe](https://github.com/vitejs/vite/commit/ce8b0feae334cc224b3f4d2fdb2bffbb62322acf)) - - -### Features - -* **plugin-vue:** add `reactivityTransform` option. ([955d0fe](https://github.com/vitejs/vite/commit/955d0fecd936b8175d7a7e4355eab855eb4567f8)) - - -### BREAKING CHANGES - -* **plugin-vue:** `refTransform` option has been replaced by -`reactivityTransform` option. Now also requires vue@^3.2.25. -* **plugin-vue:** now requires vue@^3.2.13 as peer dep - - - -## [1.10.2](https://github.com/vitejs/vite/compare/plugin-vue@1.10.1...plugin-vue@1.10.2) (2021-12-07) - - -### Bug Fixes - -* **plugin-vue:** misleading error thrown after refresh or hmr ([#5870](https://github.com/vitejs/vite/issues/5870)) ([5c07cec](https://github.com/vitejs/vite/commit/5c07cec7214948da73fbbc33c7f5c83bf7f6cd2e)) - - - -## [1.10.1](https://github.com/vitejs/vite/compare/plugin-vue@1.10.0...plugin-vue@1.10.1) (2021-11-26) - - -### Bug Fixes - -* **plugin-vue:** fix hmr issue in vuejs/core[#4358](https://github.com/vitejs/vite/issues/4358) ([709e4b0](https://github.com/vitejs/vite/commit/709e4b0428d8cdc8299b22898c76e58d66ca92c9)) - - - -# [1.10.0](https://github.com/vitejs/vite/compare/plugin-vue@1.10.0-beta.1...plugin-vue@1.10.0) (2021-11-22) - - - -# [1.10.0-beta.1](https://github.com/vitejs/vite/compare/plugin-vue@1.10.0-beta.0...plugin-vue@1.10.0-beta.1) (2021-11-19) - - -### Bug Fixes - -* plugin-vue dev scripts error in ssr-vue ([#5607](https://github.com/vitejs/vite/issues/5607)) ([502b8f2](https://github.com/vitejs/vite/commit/502b8f2b31f06d4e524d36b5566197db76f6ccda)) -* **plugin-vue:** template src isn't working when script setup ([#5418](https://github.com/vitejs/vite/issues/5418)) ([518da44](https://github.com/vitejs/vite/commit/518da447e573b6f6ec5e2b1ca837332e0e230c14)) -* **plugin-vue:** use __vccOpts for vue-class-component ([#5374](https://github.com/vitejs/vite/issues/5374)) ([c4f9db2](https://github.com/vitejs/vite/commit/c4f9db2cb375729b06f438298560045d4c488c14)) - - - -# [1.10.0-beta.0](https://github.com/vitejs/vite/compare/plugin-vue@1.9.4...plugin-vue@1.10.0-beta.0) (2021-10-28) - - - -## [1.9.4](https://github.com/vitejs/vite/compare/plugin-vue@1.9.3...plugin-vue@1.9.4) (2021-10-27) - - -### Bug Fixes - -* **plugin-vue:** exclude direct css request from hmr target ([#5422](https://github.com/vitejs/vite/issues/5422)) ([4331c26](https://github.com/vitejs/vite/commit/4331c26a5e5d7a9efc08a8b7bf7056785a1bcd94)) - - - -## [1.9.3](https://github.com/vitejs/vite/compare/plugin-vue@1.9.2...plugin-vue@1.9.3) (2021-10-05) - - -### Bug Fixes - -* **plugin-vue:** don't use object spread in the config hook ([#5155](https://github.com/vitejs/vite/issues/5155)) ([c1ce471](https://github.com/vitejs/vite/commit/c1ce471c07264db034f42573662971f0dc531df7)) - - - -## [1.9.2](https://github.com/vitejs/vite/compare/plugin-vue@1.9.1...plugin-vue@1.9.2) (2021-09-24) - - -### Bug Fixes - -* **plugin-vue:** handle rewrite default edge case with TS ([609a342](https://github.com/vitejs/vite/commit/609a342986b2d3b05ef59dc23523239938264008)) - - -### Reverts - -* Revert "feat(plugin-vue): define __VUE_SSR__ flag" ([3e2c1bf](https://github.com/vitejs/vite/commit/3e2c1bf74bb8ef583d66c67c715fdeae8d8fe432)) - - - -## [1.9.1](https://github.com/vitejs/vite/compare/plugin-vue@1.9.0...plugin-vue@1.9.1) (2021-09-23) - - -### Features - -* ~~**plugin-vue:** define __VUE_SSR__ flag ([49618c1](https://github.com/vitejs/vite/commit/49618c17f38ee54ea17b4b04d58eb5fbf3e532fe))~~ (Reverted) - - - -# [1.9.0](https://github.com/vitejs/vite/compare/plugin-vue@1.8.1...plugin-vue@1.9.0) (2021-09-21) - - -### Bug Fixes - -* **plugin-vue:** enable ts in template also for lang=tsx ([ed88df3](https://github.com/vitejs/vite/commit/ed88df30a93d759e5c4ac0f079b9f604fad2ce40)) - - -### Features - -* **plugin-vue:** support optional @vue/compiler-sfc peer dep ([b17b5ae](https://github.com/vitejs/vite/commit/b17b5ae68de50413a95fb992ceda92ec0fceaa86)) - - - -## [1.8.1](https://github.com/vitejs/vite/compare/plugin-vue@1.8.0...plugin-vue@1.8.1) (2021-09-19) - - -### Bug Fixes - -* **plugin-vue:** generate tree-shakable code ([316d7af](https://github.com/vitejs/vite/commit/316d7afc0c84e51359938a12ebe1b09ca34ea8bd)) - - - -# [1.8.0](https://github.com/vitejs/vite/compare/plugin-vue@1.7.1...plugin-vue@1.8.0) (2021-09-18) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#4545](https://github.com/vitejs/vite/issues/4545)) ([a44fd5d](https://github.com/vitejs/vite/commit/a44fd5d38679da0be2536103e83af730cda73a95)) - - -### Performance Improvements - -* **plugin-vue:** inline main script for build + avoid sourcemap generation when possible ([93d9a2d](https://github.com/vitejs/vite/commit/93d9a2d175b1a1e3fe54197856a86887b1dadb74)) - - - -## [1.7.1](https://github.com/vitejs/vite/compare/plugin-vue@1.7.0...plugin-vue@1.7.1) (2021-09-18) - - -### Bug Fixes - -* **plugin-vue:** properly handle in-template TS syntax + tests ([0a2a5e1](https://github.com/vitejs/vite/commit/0a2a5e1c8b9d2765faecfb5e4641b1c5a94575e1)) - - - -# [1.7.0](https://github.com/vitejs/vite/compare/plugin-vue@1.6.2...plugin-vue@1.7.0) (2021-09-18) - - -### Features - -* **plugin-vue:** support TS in template expressions ([01fa2ab](https://github.com/vitejs/vite/commit/01fa2abe901834c1c3168c343120429700e82983)) - - - -## [1.6.2](https://github.com/vitejs/vite/compare/plugin-vue@1.6.1...plugin-vue@1.6.2) (2021-09-08) - - -### Bug Fixes - -* **plugin-vue:** ensure descriptor in case main request is cached ([85612fe](https://github.com/vitejs/vite/commit/85612fe69da98759dbf3b5352cf47a74f20374ff)) - - - -## [1.6.1](https://github.com/vitejs/vite/compare/plugin-vue@1.6.0...plugin-vue@1.6.1) (2021-09-06) - - -### Bug Fixes - -* hmr doesn't work when modifying the code of jsx in sfc ([#4563](https://github.com/vitejs/vite/issues/4563)) ([1012367](https://github.com/vitejs/vite/commit/101236794c5d6d28591302d5552cb1c0ab8f4115)) -* **plugin-vue:** avoid applying ref transform to dependencies by default ([cd4f341](https://github.com/vitejs/vite/commit/cd4f341201d5598c3ec9cc594949e7d5304ac7ec)) - - - -# [1.6.0](https://github.com/vitejs/vite/compare/plugin-vue@1.5.0...plugin-vue@1.6.0) (2021-08-24) - - -### Features - -* **plugin-vue:** latest ref transform support ([533b002](https://github.com/vitejs/vite/commit/533b0029adc912257251b5021879ab1d676a16ab)) -* **plugin-vue:** warn compiler-sfc version mismatch ([e7263b9](https://github.com/vitejs/vite/commit/e7263b98f2e174198b322d26c6a7207d706a6639)) - - - -# [1.5.0](https://github.com/vitejs/vite/compare/plugin-vue@1.4.0...plugin-vue@1.5.0) (2021-08-24) - - - -# [1.4.0](https://github.com/vitejs/vite/compare/plugin-vue@1.3.0...plugin-vue@1.4.0) (2021-08-07) - -### Features - -* Custom Elements mode behavior changed: now only inlines the CSS and no longer exports the custom element constructor (exports the component as in normal mode). Users now need to explicitly call `defineCustomElement` on the component. This allows the custom element to be defined using an async version of the source component. - -### Bug Fixes - -* revert update dependency slash to v4 ([#4118](https://github.com/vitejs/vite/issues/4118)) ([#4519](https://github.com/vitejs/vite/issues/4519)) ([9b4fe1f](https://github.com/vitejs/vite/commit/9b4fe1fa68c522878d1bdef87d7aa02ae08e986f)) - - - -# [1.3.0](https://github.com/vitejs/vite/compare/plugin-vue@1.2.5...plugin-vue@1.3.0) (2021-07-27) - - -### Bug Fixes - -* reuse the old preprocessor after changing the lang attr ([#4224](https://github.com/vitejs/vite/issues/4224)) ([7a3c6e6](https://github.com/vitejs/vite/commit/7a3c6e616385cbc069620ae583d6739a972c0ead)) - - -### Features - -* **plugin-vue:** support importing vue files as custom elements ([3a3af6e](https://github.com/vitejs/vite/commit/3a3af6eeafbc9fc686fc909ec6a61c61283316fc)) - - - -## [1.2.5](https://github.com/vitejs/vite/compare/plugin-vue@1.2.4...plugin-vue@1.2.5) (2021-07-12) - - - -## [1.2.4](https://github.com/vitejs/vite/compare/plugin-vue@1.2.3...plugin-vue@1.2.4) (2021-06-27) - - -### Bug Fixes - -* **ssr:** normalize manifest filenames ([#3706](https://github.com/vitejs/vite/issues/3706)) ([aa8ca3f](https://github.com/vitejs/vite/commit/aa8ca3f35218c9fb48f87d3f6f4681d379ee45ca)), closes [#3303](https://github.com/vitejs/vite/issues/3303) - - - -## [1.2.3](https://github.com/vitejs/vite/compare/plugin-vue@1.2.2...plugin-vue@1.2.3) (2021-06-01) - - -### Bug Fixes - -* **plugin-vue:** rewrite default after ts compiled ([#3591](https://github.com/vitejs/vite/issues/3591)) ([ea5bafa](https://github.com/vitejs/vite/commit/ea5bafaefbafd858389f88e537cb3473b4669802)) - - - -## [1.2.2](https://github.com/vitejs/vite/compare/plugin-vue@1.2.1...plugin-vue@1.2.2) (2021-04-24) - - -### Bug Fixes - -* **plugin-vue:** add newline character before class components, fix [#2787](https://github.com/vitejs/vite/issues/2787) ([#2933](https://github.com/vitejs/vite/issues/2933)) ([8fe828e](https://github.com/vitejs/vite/commit/8fe828e9be9e9de67463af6f5dc35ebdbfdbda28)) -* **plugin-vue:** avoid duplicate import, fix [#2640](https://github.com/vitejs/vite/issues/2640) ([#2897](https://github.com/vitejs/vite/issues/2897)) ([011438d](https://github.com/vitejs/vite/commit/011438d16dc42408d5229b842d67dba28868566b)) -* **plugin-vue:** respect `hmr: false` server config, fix [#2790](https://github.com/vitejs/vite/issues/2790) ([#2797](https://github.com/vitejs/vite/issues/2797)) ([27e0c3f](https://github.com/vitejs/vite/commit/27e0c3fffd32a0ff90d06a909a5d5cc7d73f44b0)) - - - -## [1.2.1](https://github.com/vitejs/vite/compare/plugin-vue@1.2.0...plugin-vue@1.2.1) (2021-03-31) - - -### Bug Fixes - -* **plugin-vue:** allow to overwrite feature flags ([#2675](https://github.com/vitejs/vite/issues/2675)) ([a4acc16](https://github.com/vitejs/vite/commit/a4acc161e10fb6d122f808ad6211feef389d41a9)) - - - -# [1.2.0](https://github.com/vitejs/vite/compare/plugin-vue@1.1.5...plugin-vue@1.2.0) (2021-03-26) - - -### Features - -* **plugin-vue:** enable :slotted usage detection ([c40c49f](https://github.com/vitejs/vite/commit/c40c49f6fa806406364f4982fe45a69db15c204f)) - - - -## [1.1.5](https://github.com/vitejs/vite/compare/plugin-vue@1.1.4...plugin-vue@1.1.5) (2021-02-26) - - -### Bug Fixes - -* **plugin-vue:** fix hmr when emptying sfc file ([#2142](https://github.com/vitejs/vite/issues/2142)) ([493b942](https://github.com/vitejs/vite/commit/493b94259d6a499e03684d6001fea1a96d56810c)), closes [#2128](https://github.com/vitejs/vite/issues/2128) -* **plugin-vue:** handle default rewrite edge case for commented class ([2900a9a](https://github.com/vitejs/vite/commit/2900a9a6a501628588b31f7453e2fe5a71fe45ce)), closes [#2277](https://github.com/vitejs/vite/issues/2277) -* **plugin-vue:** import vue file as raw correctly ([#1923](https://github.com/vitejs/vite/issues/1923)) ([5b56d70](https://github.com/vitejs/vite/commit/5b56d70c1d173d4c5e3d9532f9c3bc6f8bfc020c)) - - - -## [1.1.4](https://github.com/vitejs/vite/compare/plugin-vue@1.1.3...plugin-vue@1.1.4) (2021-01-30) - - -### Bug Fixes - -* **plugin-vue:** handle block src pointing to dependency files ([bb7da3f](https://github.com/vitejs/vite/commit/bb7da3f0f07da6558f0e81bd82ede4cfe1785a56)), closes [#1812](https://github.com/vitejs/vite/issues/1812) - - - -## [1.1.3](https://github.com/vitejs/vite/compare/plugin-vue@1.1.2...plugin-vue@1.1.3) (2021-01-29) - - -### Bug Fixes - -* **plugin-vue:** special handling for class default export in sfc ([d3397e6](https://github.com/vitejs/vite/commit/d3397e61cd9d0761606506dcc176a1cbc845d8b5)), closes [#1476](https://github.com/vitejs/vite/issues/1476) - - - -## [1.1.2](https://github.com/vitejs/vite/compare/plugin-vue@1.1.1...plugin-vue@1.1.2) (2021-01-24) - - - -## [1.1.1](https://github.com/vitejs/vite/compare/plugin-vue@1.1.0...plugin-vue@1.1.1) (2021-01-23) - - -### Bug Fixes - -* avoid eager hmr api access ([fa37456](https://github.com/vitejs/vite/commit/fa37456584a09b52b39a61760a6d130e261886ff)) - - -### Features - -* support `base` option during dev, deprecate `build.base` ([#1556](https://github.com/vitejs/vite/issues/1556)) ([809d4bd](https://github.com/vitejs/vite/commit/809d4bd3bf62d3bc6b35f182178922d2ab2175f1)) - - - -# [1.1.0](https://github.com/vitejs/vite/compare/plugin-vue@1.0.6...plugin-vue@1.1.0) (2021-01-19) - - -### Features - -* ssr manifest for preload inference ([107e79e](https://github.com/vitejs/vite/commit/107e79e7b7d422f0d1dbe8b7b435636df7c6281c)) -* **plugin-vue:** support for vite core new ssr impl ([a93ab23](https://github.com/vitejs/vite/commit/a93ab23491ee9fee78345ddc20567e1b0ceec2a7)) - - - -## [1.0.6](https://github.com/vitejs/vite/compare/plugin-vue@1.0.5...plugin-vue@1.0.6) (2021-01-15) - - -### Bug Fixes - -* **plugin-vue:** sfc src import respect alias ([#1544](https://github.com/vitejs/vite/issues/1544)) ([d8754de](https://github.com/vitejs/vite/commit/d8754deeb16ef0d86b17dfa2a3394d0919bcd72e)), closes [#1542](https://github.com/vitejs/vite/issues/1542) - - - -## [1.0.5](https://github.com/vitejs/vite/compare/plugin-vue@1.0.4...plugin-vue@1.0.5) (2021-01-09) - - -### Bug Fixes - -* **plugin-vue:** default pug doctype ([756a0f2](https://github.com/vitejs/vite/commit/756a0f26911e5bff9c1ea3f780a0a1eccd1f1cfd)), closes [#1383](https://github.com/vitejs/vite/issues/1383) -* **plugin-vue:** pass on script and style options to compiler-sfc ([0503d42](https://github.com/vitejs/vite/commit/0503d42aaddbc4b8428c94ede07cf7b84f800cef)), closes [#1450](https://github.com/vitejs/vite/issues/1450) - - - -## [1.0.4](https://github.com/vitejs/vite/compare/plugin-vue@1.0.3...plugin-vue@1.0.4) (2021-01-04) - - -### Bug Fixes - -* **plugin-vue:** mark SFC compiler options as `Partial` ([#1316](https://github.com/vitejs/vite/issues/1316)) ([331484c](https://github.com/vitejs/vite/commit/331484c2600e96543aa8007b4940d023cb5cc19f)) - - -### Features - -* **plugin-vue:** export vue query parse API ([#1303](https://github.com/vitejs/vite/issues/1303)) ([56bcb0c](https://github.com/vitejs/vite/commit/56bcb0c475a5dff31527cad6dcd7c61fde424f5e)) - - - -## [1.0.3](https://github.com/vitejs/vite/compare/plugin-vue@1.0.2...plugin-vue@1.0.3) (2021-01-02) - - -### Bug Fixes - -* **plugin-vue:** custom block prev handling ([8dbc2b4](https://github.com/vitejs/vite/commit/8dbc2b47dd8fea4a953fb05057edb47122e2dcb7)) - - -### Code Refactoring - -* **hmr:** pass context object to `handleHotUpdate` plugin hook ([b314771](https://github.com/vitejs/vite/commit/b3147710e96a8f88ab81b2e45dbf7e7174ad976c)) - - -### BREAKING CHANGES - -* **hmr:** `handleHotUpdate` plugin hook now receives a single -`HmrContext` argument instead of multiple args. - - - -## [1.0.2](https://github.com/vitejs/vite/compare/plugin-vue@1.0.2...plugin-vue@1.0.2) (2021-01-02) - - -### Bug Fixes - -* **plugin-vue:** avoid throwing on never requested file ([48a24c1](https://github.com/vitejs/vite/commit/48a24c1fa1f64e89ca853635580911859ef5881b)) -* **plugin-vue:** custom block prev handling ([8dbc2b4](https://github.com/vitejs/vite/commit/8dbc2b47dd8fea4a953fb05057edb47122e2dcb7)) -* avoid self referencing type in plugin-vue ([9cccdaa](https://github.com/vitejs/vite/commit/9cccdaa0935ca664c8a709a89ebd1f2216565546)) -* **plugin-vue:** ensure id on descriptor ([91217f6](https://github.com/vitejs/vite/commit/91217f6d968485303e71128bb79ad4400b9b4412)) diff --git a/packages/plugin-vue/LICENSE b/packages/plugin-vue/LICENSE deleted file mode 100644 index 9c1b313d7b1816..00000000000000 --- a/packages/plugin-vue/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/plugin-vue/README.md b/packages/plugin-vue/README.md deleted file mode 100644 index 776828f8cdc96e..00000000000000 --- a/packages/plugin-vue/README.md +++ /dev/null @@ -1,176 +0,0 @@ -# @vitejs/plugin-vue [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue.svg)](https://npmjs.com/package/@vitejs/plugin-vue) - -> Note: as of `vue` 3.2.13+ and `@vitejs/plugin-vue` 1.9.0+, `@vue/compiler-sfc` is no longer required as a peer dependency. - -```js -// vite.config.js -import vue from '@vitejs/plugin-vue' - -export default { - plugins: [vue()] -} -``` - -For JSX / TSX support, [`@vitejs/plugin-vue-jsx`](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) is also needed. - -## Options - -```ts -export interface Options { - include?: string | RegExp | (string | RegExp)[] - exclude?: string | RegExp | (string | RegExp)[] - - isProduction?: boolean - - // options to pass on to vue/compiler-sfc - script?: Partial> - template?: Partial< - Pick< - SFCTemplateCompileOptions, - | 'compiler' - | 'compilerOptions' - | 'preprocessOptions' - | 'preprocessCustomRequire' - | 'transformAssetUrls' - > - > - style?: Partial> - - /** - * Transform Vue SFCs into custom elements. - * - `true`: all `*.vue` imports are converted into custom elements - * - `string | RegExp`: matched files are converted into custom elements - * - * @default /\.ce\.vue$/ - */ - customElement?: boolean | string | RegExp | (string | RegExp)[] - - /** - * Enable Vue reactivity transform (experimental). - * https://vuejs.org/guide/extras/reactivity-transform.html - * - `true`: transform will be enabled for all vue,js(x),ts(x) files except - * those inside node_modules - * - `string | RegExp`: apply to vue + only matched files (will include - * node_modules, so specify directories if necessary) - * - `false`: disable in all cases - * - * @default false - */ - reactivityTransform?: boolean | string | RegExp | (string | RegExp)[] - - /** - * Use custom compiler-sfc instance. Can be used to force a specific version. - */ - compiler?: typeof _compiler -} -``` - -## Asset URL handling - -When `@vitejs/plugin-vue` compiles the `