Skip to content

Commit

Permalink
Merge branch 'main' into feat/support-headers-configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Nov 26, 2021
2 parents e5e8cd2 + 4d0453d commit 9b0707f
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 102 deletions.
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.20"
"vue": "^3.2.23"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.20"
"vue": "^3.2.23"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"aliased-module": "file:./dir/module",
"vue": "^3.2.21"
"vue": "^3.2.23"
},
"devDependencies": {
"resolve-linked": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.21"
"vue": "^3.2.23"
}
}
2 changes: 1 addition & 1 deletion packages/playground/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "vite preview"
},
"devDependencies": {
"vue": "^3.2.21"
"vue": "^3.2.23"
}
}
2 changes: 1 addition & 1 deletion packages/playground/optimize-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"resolve-linked": "workspace:0.0.0",
"vue": "^3.2.21",
"vue": "^3.2.23",
"vuex": "^4.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/preload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.21",
"vue": "^3.2.23",
"vue-router": "^4.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/ssr-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"bcrypt": "^5.0.1",
"example-external-component": "file:example-external-component",
"vue": "^3.2.21",
"vue": "^3.2.23",
"vue-router": "^4.0.0",
"vuex": "^4.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"autoprefixer": "^10.4.0",
"tailwindcss": "^2.2.19",
"vue": "^3.2.21",
"vue": "^3.2.23",
"vue-router": "^4.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/vue-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.21"
"vue": "^3.2.23"
},
"devDependencies": {
"@vitejs/plugin-vue": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/playground/vue/Hmr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<script setup lang="ts">
import { ref } from 'vue'
import Node from './Node.vue'
let foo: number = 0
Expand Down
3 changes: 3 additions & 0 deletions packages/playground/vue/Node.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div class="node">this is node</div>
</template>
7 changes: 7 additions & 0 deletions packages/playground/vue/__tests__/vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ describe('hmr', () => {
await untilUpdated(() => page.textContent('.hmr-inc'), 'count is 100')
})

test('global hmr for some scenarios', async () => {
editFile('Hmr.vue', (code) =>
code.replace('</template>', ' <Node/>\n' + '</template>')
)
await untilUpdated(() => page.innerHTML('.node'), 'this is node')
})

test('should re-render when template is emptied', async () => {
editFile('Hmr.vue', () => '')
await untilUpdated(() => page.innerHTML('.hmr-block'), '<!---->')
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"lodash-es": "^4.17.21",
"vue": "^3.2.21"
"vue": "^3.2.23"
},
"devDependencies": {
"@vitejs/plugin-vue": "workspace:*",
Expand Down
9 changes: 9 additions & 0 deletions packages/plugin-vue/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [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/vue-next[#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)


Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vitejs/plugin-vue",
"version": "1.10.0",
"version": "1.10.1",
"license": "MIT",
"author": "Evan You",
"files": [
Expand Down Expand Up @@ -36,12 +36,12 @@
"devDependencies": {
"@rollup/pluginutils": "^4.1.1",
"@types/hash-sum": "^1.0.0",
"@vue/compiler-sfc": "^3.2.22",
"@vue/compiler-sfc": "^3.2.23",
"debug": "^4.3.2",
"hash-sum": "^2.0.0",
"rollup": "^2.59.0",
"slash": "^4.0.0",
"source-map": "^0.6.1",
"vue": "^3.2.22"
"vue": "^3.2.23"
}
}
30 changes: 24 additions & 6 deletions packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export async function handleHotUpdate(
)
const templateModule = modules.find((m) => /type=template/.test(m.url))

if (
!isEqualBlock(descriptor.script, prevDescriptor.script) ||
!isEqualBlock(descriptor.scriptSetup, prevDescriptor.scriptSetup)
) {
if (hasScriptChanged(prevDescriptor, descriptor)) {
let scriptModule: ModuleNode | undefined
if (descriptor.script?.lang && !descriptor.script.src) {
const scriptModuleRE = new RegExp(
Expand Down Expand Up @@ -174,11 +171,32 @@ export function isOnlyTemplateChanged(
next: SFCDescriptor
): boolean {
return (
isEqualBlock(prev.script, next.script) &&
isEqualBlock(prev.scriptSetup, next.scriptSetup) &&
!hasScriptChanged(prev, next) &&
prev.styles.length === next.styles.length &&
prev.styles.every((s, i) => isEqualBlock(s, next.styles[i])) &&
prev.customBlocks.length === next.customBlocks.length &&
prev.customBlocks.every((s, i) => isEqualBlock(s, next.customBlocks[i]))
)
}

function hasScriptChanged(prev: SFCDescriptor, next: SFCDescriptor): boolean {
if (!isEqualBlock(prev.script, next.script)) {
return true
}
if (!isEqualBlock(prev.scriptSetup, next.scriptSetup)) {
return true
}

// vue core #3176
// <script setup lang="ts"> prunes non-unused imports
// the imports pruning depends on template, so script may need to re-compile
// based on template changes
const prevResolvedScript = getResolvedScript(prev, false)
// this is only available in vue@^3.2.23
const prevImports = prevResolvedScript?.imports
if (prevImports) {
return next.shouldForceReload(prevImports)
}

return false
}
1 change: 0 additions & 1 deletion packages/plugin-vue/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export function resolveScript(
inlineTemplate: isUseInlineTemplate(descriptor, !options.devServer),
refTransform: options.refTransform !== false,
templateOptions: resolveTemplateCompilerOptions(descriptor, options, ssr),
// @ts-ignore TODO remove ignore when we support this in @vue/compiler-sfc
sourceMap: options.sourceMap
})

Expand Down
Loading

0 comments on commit 9b0707f

Please sign in to comment.