Skip to content

Commit 3e0662a

Browse files
authored
Merge branch 'main' into custom-comp-id
2 parents 989bd9c + 23ea2f9 commit 3e0662a

File tree

33 files changed

+2339
-1759
lines changed

33 files changed

+2339
-1759
lines changed

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,34 @@
3636
"ci-publish": "tsx scripts/publishCI.ts"
3737
},
3838
"devDependencies": {
39-
"@babel/types": "^7.25.6",
40-
"@eslint/js": "^9.9.1",
39+
"@babel/types": "^7.26.0",
40+
"@eslint/js": "^9.14.0",
4141
"@types/babel__core": "^7.20.5",
4242
"@types/convert-source-map": "^2.0.3",
4343
"@types/debug": "^4.1.12",
4444
"@types/fs-extra": "^11.0.4",
45-
"@types/node": "^22.5.1",
45+
"@types/node": "^22.9.0",
4646
"@vitejs/release-scripts": "^1.3.2",
4747
"conventional-changelog-cli": "^5.0.0",
48-
"eslint": "^9.9.1",
49-
"eslint-plugin-import-x": "^4.1.1",
50-
"eslint-plugin-n": "^17.10.2",
48+
"eslint": "^9.14.0",
49+
"eslint-plugin-import-x": "^4.4.0",
50+
"eslint-plugin-n": "^17.13.1",
5151
"eslint-plugin-regexp": "^2.6.0",
52-
"execa": "^9.3.1",
52+
"execa": "^9.5.1",
5353
"fs-extra": "^11.2.0",
54-
"lint-staged": "^15.2.9",
55-
"npm-run-all2": "^6.2.2",
56-
"picocolors": "^1.0.1",
57-
"playwright-chromium": "^1.46.1",
54+
"lint-staged": "^15.2.10",
55+
"npm-run-all2": "^7.0.1",
56+
"picocolors": "^1.1.1",
57+
"playwright-chromium": "^1.48.2",
5858
"prettier": "3.3.3",
59-
"rollup": "^4.24.0",
59+
"rollup": "^4.25.0",
6060
"simple-git-hooks": "^2.11.1",
61-
"tsx": "^4.19.0",
62-
"typescript": "^5.5.4",
63-
"typescript-eslint": "^8.3.0",
61+
"tsx": "^4.19.2",
62+
"typescript": "^5.6.3",
63+
"typescript-eslint": "^8.13.0",
6464
"unbuild": "2.0.0",
6565
"vite": "catalog:",
66-
"vitest": "^2.0.5",
66+
"vitest": "^2.1.4",
6767
"vue": "catalog:"
6868
},
6969
"simple-git-hooks": {
@@ -83,7 +83,7 @@
8383
"eslint --cache --fix"
8484
]
8585
},
86-
"packageManager": "pnpm@9.9.0",
86+
"packageManager": "pnpm@9.12.3",
8787
"pnpm": {
8888
"overrides": {
8989
"@vitejs/plugin-vue": "workspace:*"

packages/plugin-vue-jsx/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 4.1.0 (2024-11-11)
2+
3+
* feat: support tsPluginOptions (#445) ([fdb3590](https://github.com/vitejs/vite-plugin-vue/commit/fdb3590)), closes [#445](https://github.com/vitejs/vite-plugin-vue/issues/445)
4+
* fix(deps): update all non-major dependencies (#421) ([e3a7fec](https://github.com/vitejs/vite-plugin-vue/commit/e3a7fec)), closes [#421](https://github.com/vitejs/vite-plugin-vue/issues/421)
5+
* fix(deps): update all non-major dependencies (#439) ([e432bcb](https://github.com/vitejs/vite-plugin-vue/commit/e432bcb)), closes [#439](https://github.com/vitejs/vite-plugin-vue/issues/439)
6+
* fix(plugin-jsx): work around bun bug for ssrRegisterHelper (#380) ([9c2b620](https://github.com/vitejs/vite-plugin-vue/commit/9c2b620)), closes [#380](https://github.com/vitejs/vite-plugin-vue/issues/380) [#376](https://github.com/vitejs/vite-plugin-vue/issues/376)
7+
* perf: use `hash` to replace `createHash` (#460) ([de88394](https://github.com/vitejs/vite-plugin-vue/commit/de88394)), closes [#460](https://github.com/vitejs/vite-plugin-vue/issues/460)
8+
* refactor(vue-jsx): remove extraneous import ([ab2516a](https://github.com/vitejs/vite-plugin-vue/commit/ab2516a))
9+
10+
11+
112
## <small>4.0.1 (2024-08-14)</small>
213

314
* chore: use pnpm catalog for shared deps ([0735e18](https://github.com/vitejs/vite-plugin-vue/commit/0735e18))

packages/plugin-vue-jsx/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vitejs/plugin-vue-jsx",
3-
"version": "4.0.1",
3+
"version": "4.1.0",
44
"type": "commonjs",
55
"license": "MIT",
66
"author": "Evan You",
@@ -35,9 +35,9 @@
3535
},
3636
"homepage": "https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx#readme",
3737
"dependencies": {
38-
"@babel/core": "^7.25.2",
39-
"@babel/plugin-transform-typescript": "^7.25.2",
40-
"@vue/babel-plugin-jsx": "^1.2.2"
38+
"@babel/core": "^7.26.0",
39+
"@babel/plugin-transform-typescript": "^7.25.9",
40+
"@vue/babel-plugin-jsx": "^1.2.5"
4141
},
4242
"devDependencies": {
4343
"vite": "catalog:"

packages/plugin-vue-jsx/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export * from './types'
1313
const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper'
1414
const ssrRegisterHelperCode =
1515
`import { useSSRContext } from "vue"\n` +
16-
`export ${ssrRegisterHelper.toString()}`
16+
// the const here is just to work around the Bun bug where
17+
// Function.toString() isn't working as intended
18+
// https://github.com/oven-sh/bun/issues/9543
19+
`export const ssrRegisterHelper = ${ssrRegisterHelper.toString()}`
1720

1821
/**
1922
* This function is serialized with toString() and evaluated as a virtual
@@ -41,6 +44,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
4144
exclude,
4245
babelPlugins = [],
4346
defineComponentName = ['defineComponent'],
47+
tsPluginOptions = {},
4448
...babelPluginOptions
4549
} = options
4650
const filter = createFilter(include || /\.[jt]sx$/, exclude)
@@ -97,7 +101,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
97101
(r) => r.default,
98102
),
99103
// @ts-ignore
100-
{ isTSX: true, allowExtensions: true },
104+
{ ...tsPluginOptions, isTSX: true, allowExtensions: true },
101105
])
102106
}
103107

packages/plugin-vue-jsx/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export interface Options extends VueJSXPluginOptions, FilterOptions {
1010
babelPlugins?: any[]
1111
/** @default ['defineComponent'] */
1212
defineComponentName?: string[]
13+
tsPluginOptions?: any
1314
}

packages/plugin-vue/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## <small>5.1.5 (2024-11-11)</small>
2+
3+
* chore: fix typo (#464) ([4a811b0](https://github.com/vitejs/vite-plugin-vue/commit/4a811b0)), closes [#464](https://github.com/vitejs/vite-plugin-vue/issues/464)
4+
* chore(deps): update dependency rollup to ^4.24.0 (#448) ([0fc9cd0](https://github.com/vitejs/vite-plugin-vue/commit/0fc9cd0)), closes [#448](https://github.com/vitejs/vite-plugin-vue/issues/448)
5+
* chore(deps): update dependency rollup to ^4.25.0 (#472) ([91210cc](https://github.com/vitejs/vite-plugin-vue/commit/91210cc)), closes [#472](https://github.com/vitejs/vite-plugin-vue/issues/472)
6+
* chore(deps): update upstream (#462) ([5625fc9](https://github.com/vitejs/vite-plugin-vue/commit/5625fc9)), closes [#462](https://github.com/vitejs/vite-plugin-vue/issues/462)
7+
* fix(deps): update all non-major dependencies (#439) ([e432bcb](https://github.com/vitejs/vite-plugin-vue/commit/e432bcb)), closes [#439](https://github.com/vitejs/vite-plugin-vue/issues/439)
8+
* fix(hmr): re-resolve script after type dep changed (#446) ([8f9c624](https://github.com/vitejs/vite-plugin-vue/commit/8f9c624)), closes [#446](https://github.com/vitejs/vite-plugin-vue/issues/446)
9+
* fix(hmr): should reload if relies file changed after re-render (#471) ([62b17f3](https://github.com/vitejs/vite-plugin-vue/commit/62b17f3)), closes [#471](https://github.com/vitejs/vite-plugin-vue/issues/471)
10+
* perf: use `hash` to replace `createHash` (#460) ([de88394](https://github.com/vitejs/vite-plugin-vue/commit/de88394)), closes [#460](https://github.com/vitejs/vite-plugin-vue/issues/460)
11+
12+
13+
114
## <small>5.1.4 (2024-09-16)</small>
215

316
* chore: format ([07b29a6](https://github.com/vitejs/vite-plugin-vue/commit/07b29a6))

packages/plugin-vue/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vitejs/plugin-vue",
3-
"version": "5.1.4",
3+
"version": "5.1.5",
44
"type": "commonjs",
55
"license": "MIT",
66
"author": "Evan You",
@@ -41,10 +41,10 @@
4141
"devDependencies": {
4242
"@jridgewell/gen-mapping": "^0.3.5",
4343
"@jridgewell/trace-mapping": "^0.3.25",
44-
"debug": "^4.3.6",
45-
"rollup": "^4.24.0",
44+
"debug": "^4.3.7",
45+
"rollup": "^4.25.0",
4646
"slash": "^5.1.0",
47-
"source-map-js": "^1.2.0",
47+
"source-map-js": "^1.2.1",
4848
"vite": "catalog:",
4949
"vue": "catalog:"
5050
}

packages/plugin-vue/src/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'node:fs'
22
import type { Plugin, ViteDevServer } from 'vite'
3-
import { createFilter } from 'vite'
3+
import { createFilter, normalizePath } from 'vite'
44
/* eslint-disable import/no-duplicates */
55
import type {
66
SFCBlock,
@@ -19,7 +19,7 @@ import {
1919
getSrcDescriptor,
2020
getTempSrcDescriptor,
2121
} from './utils/descriptorCache'
22-
import { clearScriptCache, getResolvedScript, typeDepToSFCMap } from './script'
22+
import { clearScriptCache, resolveScript, typeDepToSFCMap } from './script'
2323
import { transformMain } from './main'
2424
import { handleHotUpdate, handleTypeDepChange } from './handleHotUpdate'
2525
import { transformTemplateAsModule } from './template'
@@ -217,6 +217,12 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
217217
},
218218

219219
handleHotUpdate(ctx) {
220+
ctx.server.ws.send({
221+
type: 'custom',
222+
event: 'file-changed',
223+
data: { file: normalizePath(ctx.file) },
224+
})
225+
220226
if (options.value.compiler.invalidateTypeCache) {
221227
options.value.compiler.invalidateTypeCache(ctx.file)
222228
}
@@ -317,7 +323,12 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
317323
let block: SFCBlock | null | undefined
318324
if (query.type === 'script') {
319325
// handle <script> + <script setup> merge via compileScript()
320-
block = getResolvedScript(descriptor, ssr)
326+
block = resolveScript(
327+
descriptor,
328+
options.value,
329+
ssr,
330+
customElementFilter.value(filename),
331+
)
321332
} else if (query.type === 'template') {
322333
block = descriptor.template!
323334
} else if (query.type === 'style') {

packages/plugin-vue/src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function transformMain(
5050
// for vue files, create descriptor from fs read to be consistent with
5151
// logic in handleHotUpdate()
5252
// for non vue files, e.g. md files in vitepress, we assume
53-
// `hmrContext.read` is overwriten so handleHotUpdate() is dealing with
53+
// `hmrContext.read` is overwritten so handleHotUpdate() is dealing with
5454
// post-transform code, so we populate the descriptor with post-transform
5555
// code here as well.
5656
filename.endsWith('.vue') ? undefined : code,
@@ -148,9 +148,20 @@ export async function transformMain(
148148
`typeof __VUE_HMR_RUNTIME__ !== 'undefined' && ` +
149149
`__VUE_HMR_RUNTIME__.createRecord(_sfc_main.__hmrId, _sfc_main)`,
150150
)
151+
output.push(
152+
`import.meta.hot.on('file-changed', ({ file }) => {`,
153+
` __VUE_HMR_RUNTIME__.CHANGED_FILE = file`,
154+
`})`,
155+
)
151156
// check if the template is the only thing that changed
152157
if (prevDescriptor && isOnlyTemplateChanged(prevDescriptor, descriptor)) {
153-
output.push(`export const _rerender_only = true`)
158+
// #7 only consider re-render if the HMR is triggered by the current component,
159+
// otherwise reload. Due to vite will cache the transform result. If the HMR
160+
// is triggered by other files that the current component relies on, a reload
161+
// is required.
162+
output.push(
163+
`export const _rerender_only = __VUE_HMR_RUNTIME__.CHANGED_FILE === ${JSON.stringify(normalizePath(filename))}`,
164+
)
154165
}
155166
output.push(
156167
`import.meta.hot.accept(mod => {`,

playground/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "@vitejs/vite-playground",
33
"private": true,
44
"version": "1.0.0",
5+
"type": "module",
56
"devDependencies": {
6-
"@types/node": "^22.5.1",
7+
"@types/node": "^22.9.0",
78
"convert-source-map": "^2.0.0",
89
"css-color-names": "^1.0.1",
910
"kill-port": "^1.6.1",

0 commit comments

Comments
 (0)