Skip to content

Commit b94ff9d

Browse files
committed
feat: WIP
1 parent 2ac92f0 commit b94ff9d

File tree

14 files changed

+4355
-90
lines changed

14 files changed

+4355
-90
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 天泽
3+
Copyright (c) 2020 Chengzhang
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

example/A.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default () => <div>23411dd</div>;

example/App.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineComponent } from 'vue';
2+
import A from './A';
3+
import { B } from './B';
4+
5+
const App = defineComponent({
6+
data() {
7+
return {
8+
a: 1
9+
}
10+
},
11+
render() {
12+
const { a } = this;
13+
return (
14+
<>
15+
{a}
16+
<div onClick={() => { this.a++; }}>Hello World!</div>
17+
<A />
18+
<B />
19+
</>
20+
)
21+
}
22+
});
23+
24+
export default App;

example/B.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineComponent } from 'vue';
2+
3+
const B = defineComponent({
4+
data() {
5+
return {
6+
a: 1
7+
}
8+
},
9+
render() {
10+
const { a } = this;
11+
return (
12+
<>
13+
<div onClick={() => { this.a++; }}>{a}d4s</div>
14+
<span>2</span>
15+
</>
16+
);
17+
}
18+
});
19+
20+
export {
21+
B
22+
};

example/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue';
2+
import App from './App';
3+
4+
createApp(App).mount('#app');

example/webpack.config.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const path = require("path");
2+
3+
const babelConfig = {
4+
plugins: ["@vue/babel-plugin-jsx"],
5+
};
6+
7+
module.exports = {
8+
mode: "development",
9+
entry: {
10+
app: path.resolve(__dirname, "./index.js"),
11+
},
12+
output: {
13+
path: path.resolve(__dirname, "./dist"),
14+
publicPath: "/dist/",
15+
},
16+
module: {
17+
rules: [
18+
{
19+
test: /\.(js|jsx)$/,
20+
use: [
21+
{
22+
loader: "babel-loader",
23+
options: babelConfig,
24+
},
25+
"vue-jsx-hot-loader",
26+
],
27+
},
28+
],
29+
},
30+
devServer: {
31+
historyApiFallback: true,
32+
hot: true,
33+
open: true,
34+
},
35+
resolve: {
36+
extensions: [".jsx", ".js"],
37+
},
38+
resolveLoader: {
39+
alias: {
40+
"vue-jsx-hot-loader": require.resolve("../"),
41+
},
42+
},
43+
};

index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Demo</title>
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="/dist/app.js"></script>
10+
</body>
11+
</html>

jest.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testTimeout: 30000,
4+
testEnvironment: 'node',
5+
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/'],
6+
}

package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
"version": "1.0.0",
44
"description": "Tweak Vue components written in JSX in real time.",
55
"main": "dist/index.js",
6-
"scripts": {},
6+
"types": "dist/index.d.ts",
7+
"scripts": {
8+
"dev": "tsc -w",
9+
"build": "tsc",
10+
"test": "jest --coverage",
11+
"dev-example": "webpack-dev-server --config example/webpack.config.js",
12+
"prepublishOnly": "tsc"
13+
},
714
"files": [
815
"dist"
916
],
@@ -26,11 +33,19 @@
2633
"@babel/parser": "^7.0.0",
2734
"@babel/traverse": "^7.0.0",
2835
"hash-sum": "^2.0.0",
29-
"loader-utils": "^2.0.0"
36+
"loader-utils": "^2.0.0",
37+
"lodash-es": "^4.17.20"
3038
},
3139
"devDependencies": {
32-
"@types/webpack": "^4.41.22",
40+
"@babel/core": "^7.12.10",
41+
"@types/loader-utils": "^2.0.1",
42+
"@vue/babel-plugin-jsx": "^1.0.0",
43+
"babel-loader": "^8.2.2",
44+
"jest": "^26.6.3",
3345
"typescript": "^4.0.3",
34-
"webpack": "^4.44.2"
46+
"vue": "^3.0.5",
47+
"webpack": "^4.44.2",
48+
"webpack-cli": "^3.0.0",
49+
"webpack-dev-server": "^3.11.1"
3550
}
3651
}

src/hotReload.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)