Skip to content

Commit c39efd0

Browse files
committed
👷 [cli/build] remove dts and only rename types index file to 'mts' and 'cts'
1 parent ae3d536 commit c39efd0

4 files changed

Lines changed: 20 additions & 41 deletions

File tree

‎cli/build/config/build.ts‎

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const pRm = promisify(fs.rm);
3232

3333
const execSync = (cmd: string) => {
3434
return new Promise((resolve, reject) => {
35-
exec(cmd, (res,stdout) => {
35+
exec(cmd, (res, stdout) => {
3636
if (res) {
3737
console.error(res);
3838
reject(false);
@@ -43,30 +43,12 @@ const execSync = (cmd: string) => {
4343
});
4444
};
4545

46-
// tsc shuimo-ui.mjs --target esnext --declaration --emitDeclarationOnly --allowJs --skipLibCheck --declarationMap --exactOptionalPropertyTypes
4746

48-
const tscDeclaration = (path: string, fileName: string) => {
49-
50-
const filePath = `./config/output/dist/${path}/${fileName}`;
51-
const outPath = `./config/output/dist/${path}`;
52-
53-
const args = [
54-
`../../node_modules/.bin/vue-tsc ${filePath}`,
55-
`--outDir ${outPath}`,
56-
'--target esnext',
57-
'--declaration',
58-
'--emitDeclarationOnly',
59-
'--allowJs',
60-
'--skipLibCheck',
61-
'--declarationMap',
62-
];
63-
64-
return execSync(args.join(' '));
65-
};
6647
const init = (lib: 'vue' | 'react' | 'lit') => {
6748
const cp = async (name: string, path: string = '', type: 'file' | 'document' = 'document') => {
6849
return pCp(`../../${path}${name}`, `./config/output/${name}`, type === 'document' ? { recursive: true } : undefined);
6950
};
51+
7052
const rm = (path: string, options?: RmOptions) => {
7153
return pRm(path, options ?? { recursive: true, force: true });
7254
};
@@ -88,13 +70,21 @@ const init = (lib: 'vue' | 'react' | 'lit') => {
8870
};
8971

9072

91-
return { cp, cpLib, rename, rmLib };
73+
const renameTypes = async () => {
74+
await Promise.all([
75+
pCp(`./config/output/types/shuimo-ui.d.ts`, `./config/output/types/shuimo-ui.d.mts`),
76+
pCp(`./config/output/types/shuimo-ui.d.ts`, `./config/output/types/shuimo-ui.d.cts`),
77+
]);
78+
return rm(`./config/output/types/shuimo-ui.d.ts`);
79+
};
80+
81+
return { cp, cpLib, rename, rmLib, renameTypes };
9282

9383
};
9484

9585
const run = async () => {
9686

97-
const { cp, rename, cpLib, rmLib } = init('vue');
87+
const { cp, rename, cpLib, rmLib, renameTypes } = init('vue');
9888

9989
const removeRes = await rmLib('dist');
10090
const buildRes = await execSync('vite build -c ./config/vue.config.ts');
@@ -114,17 +104,10 @@ const run = async () => {
114104
cpLib('types'),
115105
cpLib('dist'),
116106
cpLib('index.ts'),
117-
cpLib('package.json', '', 'file')
107+
cpLib('package.json', '', 'file'),
118108
]);
119109

120-
if (res.every(r => r)) {
121-
console.log('build success, now build ts declaration file');
122-
Promise.all([
123-
// tscDeclaration('es', 'shuimo-ui.mjs'),
124-
tscDeclaration('cjs', 'shuimo-ui.cjs'),
125-
tscDeclaration('umd', 'shuimo-ui.umd.js')
126-
]);
127-
}
110+
await renameTypes()
128111

129112

130113
// todo remove "@shuimo-design/types": "workspace:*"

‎cli/build/config/vue.config.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ export default defineConfig({
2525
plugins: [
2626
lightningcss({ drafts: { nesting: true }, browserslist: '>= 0.25%' }),
2727
vue({ include: [/\.vue$/], exclude: ['**/react/*.tsx'] }),
28-
vueJSX(),
29-
dts({
30-
outDir: `${outputRoot}/es`,
31-
staticImport: true,
32-
entryRoot: path.resolve(__dirname, '../../../packages/vue')
33-
})
28+
vueJSX()
3429
],
3530
resolve: {
3631
alias: {
@@ -53,6 +48,7 @@ export default defineConfig({
5348
case 'umd':
5449
return `umd/shuimo-ui.umd.js`;
5550
}
51+
return entryName;
5652
},
5753
entry: getPath('./index.ts')
5854
},

‎packages/vue/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export {
151151
MVirtualList
152152
};
153153

154-
export function createMUI(options: MUIOption | undefined) {
154+
export function createMUI(options: MUIOption | undefined = {}) {
155155
return {
156156
install: (app: App) => {
157157
// todo support nuxt

‎packages/vue/package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"test:update": "vitest -u",
1919
"coverage": "vitest --coverage"
2020
},
21-
"types": "./dist/es/shuimo-ui.d.mts",
21+
"types": "./types/shuimo-ui.d.mts",
2222
"main": "./dist/umd/shuimo-ui.umd.js",
2323
"module": "./dist/es/shuimo-ui.mjs",
2424
"exports": {
2525
".": {
2626
"import": {
27-
"types": "./dist/es/shuimo-ui.d.mts",
27+
"types": "./types/shuimo-ui.d.mts",
2828
"default": "./dist/es/shuimo-ui.mjs"
2929
},
3030
"require": {
31-
"types": "./dist/cjs/shuimo-ui.d.cts",
31+
"types": "./types/shuimo-ui.d.cts",
3232
"default": "./dist/cjs/shuimo-ui.cjs"
3333
}
3434
},

0 commit comments

Comments
 (0)