Skip to content

Commit dc83831

Browse files
committed
v0.1.1
1 parent 9cb6af7 commit dc83831

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
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.0",
3+
"version": "0.1.1",
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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,20 @@ const hasJSX = (file: File) => {
2727
export default function loader(
2828
this: webpack.loader.LoaderContext,
2929
source: string,
30-
sourceMap: string
3130
) {
3231
const loaderContext = this;
3332
loaderContext.cacheable?.();
34-
const isDev = process.env.NODE_ENV === 'development';
3533

36-
if (isDev) {
37-
loaderContext.callback(null, source, sourceMap);
34+
const isDev = loaderContext.mode === 'development';
35+
36+
if (!isDev) {
37+
return source;
3838
}
3939

4040
const file = parse(source, { sourceType: 'module', plugins: ['jsx', 'typescript'] });
4141

4242
if (!hasJSX(file)) {
43-
loaderContext.callback(null, source, sourceMap);
44-
return;
43+
return source;
4544
}
4645

4746
const webpackRemainingChain = loaderUtils.getRemainingRequest(loaderContext).split('!');
@@ -124,5 +123,5 @@ export default function loader(
124123
`
125124
}
126125

127-
loaderContext.callback(null, source, sourceMap);
126+
return source;
128127
};

0 commit comments

Comments
 (0)