-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathvaltio.ts
57 lines (52 loc) · 927 Bytes
/
valtio.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { winPath } from '@umijs/utils';
import { dirname } from 'path';
import { IApi } from 'umi';
// TODO:
// - generator
// - builtinStore
// - lint
export default (api: IApi) => {
api.describe({
key: 'valtio',
config: {
schema({ zod }) {
return zod.object({});
},
},
enableBy: api.EnableBy.config,
});
const libPath = winPath(
dirname(require.resolve('@umijs/valtio/package.json')),
);
api.onGenerateFiles(() => {
api.writeTmpFile({
path: 'index.ts',
content: `
export {
proxy,
useSnapshot,
snapshot,
subscribe,
subscribeKey,
proxyWithComputed,
proxyWithHistory,
proxyWithDevtools,
proxyMap,
proxySet,
derive,
underive,
useProxy,
ref,
watch,
} from '${libPath}';
`,
});
});
api.modifyConfig((memo) => {
memo.alias = {
...memo.alias,
'@umijs/valtio': libPath,
};
return memo;
});
};