Skip to content

Commit 634704f

Browse files
committed
feat: auto treeshake devtools on prod
1 parent 5d990df commit 634704f

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

devtools/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if (process.env.NODE_ENV === "production") {
2+
module.exports = {
3+
VueQueryDevTools: function () {
4+
return null;
5+
},
6+
VueQueryDevToolsPanel: function () {
7+
return null;
8+
},
9+
};
10+
} else {
11+
module.exports = require("../lib/devtools-bundle");
12+
}

devtools/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"internal": true,
3+
"main": "/index.js",
4+
"module": "/index.js",
5+
"types": "../lib/devtools/index.d.ts"
6+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Vue bindings for react-query",
55
"main": "lib/index.js",
66
"files": [
7-
"/lib"
7+
"/lib",
8+
"/devtools"
89
],
910
"scripts": {
1011
"build": "rollup -c rollup.config.ts",

rollup.config.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import autoExternal from "rollup-plugin-auto-external";
33
import postcss from "rollup-plugin-postcss";
44
import typescript from "rollup-plugin-typescript2";
55
import vue from "rollup-plugin-vue";
6+
67
const common = {
78
plugins: [
89
resolve(),
@@ -19,26 +20,24 @@ const common = {
1920
include: "src/**",
2021
exclude: ["node_modules/**", "tests"],
2122
},
22-
}
23+
};
2324
export default [
2425
{
2526
input: "src/index.ts",
2627
output: {
2728
dir: "lib",
28-
name: "VueQuery",
2929
format: "esm",
30-
sourcemap: true
30+
sourcemap: true,
3131
},
32-
...common
32+
...common,
3333
},
3434
{
3535
input: "src/devtools/index.ts",
3636
output: {
37-
file: 'lib/devtools.js',
38-
name: "VueQueryDevtools",
37+
file: "lib/devtools-bundle.js",
3938
format: "esm",
40-
sourcemap: true
39+
sourcemap: true,
4140
},
42-
...common
43-
}
41+
...common,
42+
},
4443
];

0 commit comments

Comments
 (0)