Skip to content

Commit 388c2e8

Browse files
committed
v0.1.2
1 parent dc83831 commit 388c2e8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

example/webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ module.exports = {
4040
"vue-jsx-hot-loader": require.resolve("../"),
4141
},
4242
},
43+
devtool: "cheap-module-eval-source-map",
4344
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ant-design-vue/vue-jsx-hot-loader",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Tweak Vue components written in JSX in real time.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default function loader(
100100
if (hotComponents.length) {
101101
if (defaultIdentifier) {
102102
const { name } = defaultIdentifier as t.Identifier;
103-
source.replace(
103+
source = source.replace(
104104
/export default defineComponent/g,
105105
`const ${name} = defineComponent`
106106
) + `\nexport default ${name}`
@@ -114,13 +114,12 @@ export default function loader(
114114
callbackCode += `\n__VUE_HMR_RUNTIME__.reload("${id}", ${local})`
115115
}
116116

117-
source += `
118-
/* hot reload */
119-
if (module.hot) {
120-
module.hot.accept()
121-
${callbackCode}
122-
}
123-
`
117+
source +=
118+
`\n/* hot reload */` +
119+
`\nif (module.hot) {` +
120+
`\n module.hot.accept()` +
121+
`\n ${callbackCode}` +
122+
`\n}`
124123
}
125124

126125
return source;

0 commit comments

Comments
 (0)