Skip to content

Commit 9572d40

Browse files
authored
fix: use code.include and code.exclude instead of pure regex (#171)
1 parent 0a367b6 commit 9572d40

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/plugins/hydration.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export const InjectHydrationPlugin = createUnplugin(() => {
2121
include: /.(vue|ts|js|tsx|jsx)$/,
2222
exclude: [skipPath, EXCLUDE_NODE_MODULES],
2323
},
24-
code: /defineNuxtComponent|defineComponent/,
24+
code: {
25+
include: [DEFINE_COMPONENT_RE, DEFINE_NUXT_COMPONENT_RE],
26+
},
2527
},
2628
async handler(code, id) {
2729
const m = new MagicString(code)
@@ -90,7 +92,9 @@ export const InjectHydrationPlugin = createUnplugin(() => {
9092
include: INCLUDE_VUE_RE,
9193
exclude: [skipPath, EXCLUDE_NODE_MODULES],
9294
},
93-
code: /(?!defineComponent|defineNuxtComponent)/,
95+
code: {
96+
exclude: [DEFINE_COMPONENT_RE, DEFINE_NUXT_COMPONENT_RE],
97+
},
9498
},
9599

96100
handler(code, id) {

0 commit comments

Comments
 (0)