From 6e395c5ff00c1bef236943b481d692868082d448 Mon Sep 17 00:00:00 2001 From: saqqdy Date: Sun, 12 Jun 2022 16:37:35 +0800 Subject: [PATCH 1/3] build scripts --- build/plugins/index.ts | 1 + build/plugins/noop.ts | 9 ++++++++ build/tasks/buildLib.ts | 49 +++++++++++++---------------------------- 3 files changed, 25 insertions(+), 34 deletions(-) create mode 100644 build/plugins/noop.ts diff --git a/build/plugins/index.ts b/build/plugins/index.ts index 2f525516..f374d2d2 100644 --- a/build/plugins/index.ts +++ b/build/plugins/index.ts @@ -13,3 +13,4 @@ export { default as json } from './json' export { default as cssOnly } from './cssOnly' export { default as commonjs } from './commonjs' export { default as filesize } from './filesize' +export { default as noop } from './noop' diff --git a/build/plugins/noop.ts b/build/plugins/noop.ts new file mode 100644 index 00000000..a9de4b2a --- /dev/null +++ b/build/plugins/noop.ts @@ -0,0 +1,9 @@ +import type { Plugin } from 'rollup' + +function noop() { + return { + name: 'noop' + } +} + +export default noop() as Plugin diff --git a/build/tasks/buildLib.ts b/build/tasks/buildLib.ts index be4b0196..e69f7be0 100644 --- a/build/tasks/buildLib.ts +++ b/build/tasks/buildLib.ts @@ -19,6 +19,7 @@ import { minify, nodeExternals, nodeResolve, + noop, shebang // visual, } from '../plugins/index' @@ -156,6 +157,18 @@ export async function buildLib() { } ) } + // dts + if (dts !== false) { + writeOptions.push({ + file: resolve( + PACKAGE, + name, + 'lib', + fn.replace(/\.ts$/, '.d.ts') + ), + format: 'es' + }) + } const rollupConfig = { input, @@ -170,6 +183,8 @@ export async function buildLib() { customResolver: nodeResolve() as ResolverObject }), nodeResolve(), + dts !== false ? nodeExternals() : noop, + dts !== false ? dtsPlugin : noop, json, commonjs, shebang(), @@ -183,40 +198,6 @@ export async function buildLib() { ]) } - // dts - if (dts !== false) { - rollupConfig.plugins.push(nodeExternals(), dtsPlugin) - writeOptions.push({ - file: resolve( - PACKAGE, - name, - 'lib', - fn.replace(/\.ts$/, '.d.ts') - ), - format: 'es' - }) - // const rollupDtsConfig = { - // input, - // plugins: [nodeExternals(), dtsPlugin], - // external: [...externals, ...external] - // } - // const writeDtsOptions: OutputOptions[] = [ - // { - // file: resolve( - // PACKAGE, - // name, - // 'lib', - // fn.replace(/\.ts$/, '.d.ts') - // ), - // format: 'es' - // } - // ] - // const dtsBundle = await rollup(rollupDtsConfig) - // await Promise.all([ - // writeDtsOptions.map(option => dtsBundle.write(option)) - // ]) - } - const bundle = await rollup(rollupConfig) await Promise.all( writeOptions.map(option => bundle.write(option)) From 1fefd6679026041491016b55ab1f1907b12787de Mon Sep 17 00:00:00 2001 From: saqqdy Date: Sun, 12 Jun 2022 17:02:23 +0800 Subject: [PATCH 2/3] 3.0.0 --- packages/ui/components.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/ui/components.d.ts b/packages/ui/components.d.ts index 4459d12b..fa5ebbbc 100644 --- a/packages/ui/components.d.ts +++ b/packages/ui/components.d.ts @@ -7,6 +7,8 @@ declare module '@vue/runtime-core' { export interface GlobalComponents { Box: typeof import('./src/components/box/index.vue')['default'] Button: typeof import('./src/components/button/index.vue')['default'] + Cell: typeof import('./src/components/cell_bak/cell.vue')['default'] + Checkbox_bak: typeof import('./src/components/checkbox_bak/index.vue')['default'] Collapse: typeof import('./src/components/collapse/index.vue')['default'] CollapseItem: typeof import('./src/components/collapse-item/index.vue')['default'] ElButton: typeof import('element-plus/es')['ElButton'] @@ -14,6 +16,7 @@ declare module '@vue/runtime-core' { ElInput: typeof import('element-plus/es')['ElInput'] ElOption: typeof import('element-plus/es')['ElOption'] ElSelect: typeof import('element-plus/es')['ElSelect'] + Group: typeof import('./src/components/group_bak/group.vue')['default'] Nav: typeof import('./src/components/nav.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] From 3d85fdcc534329f889a71c80cc05e036ce33836f Mon Sep 17 00:00:00 2001 From: saqqdy Date: Sun, 12 Jun 2022 17:25:00 +0800 Subject: [PATCH 3/3] 3.0.0 --- build/plugins/noop.ts | 5 ++++- build/tasks/buildLib.ts | 40 ++++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/build/plugins/noop.ts b/build/plugins/noop.ts index a9de4b2a..2e0b340c 100644 --- a/build/plugins/noop.ts +++ b/build/plugins/noop.ts @@ -2,7 +2,10 @@ import type { Plugin } from 'rollup' function noop() { return { - name: 'noop' + name: 'noop', + renderChunk(code: string) { + return { code } + } } } diff --git a/build/tasks/buildLib.ts b/build/tasks/buildLib.ts index e69f7be0..34f4268d 100644 --- a/build/tasks/buildLib.ts +++ b/build/tasks/buildLib.ts @@ -19,7 +19,6 @@ import { minify, nodeExternals, nodeResolve, - noop, shebang // visual, } from '../plugins/index' @@ -157,18 +156,6 @@ export async function buildLib() { } ) } - // dts - if (dts !== false) { - writeOptions.push({ - file: resolve( - PACKAGE, - name, - 'lib', - fn.replace(/\.ts$/, '.d.ts') - ), - format: 'es' - }) - } const rollupConfig = { input, @@ -183,8 +170,6 @@ export async function buildLib() { customResolver: nodeResolve() as ResolverObject }), nodeResolve(), - dts !== false ? nodeExternals() : noop, - dts !== false ? dtsPlugin : noop, json, commonjs, shebang(), @@ -197,11 +182,34 @@ export async function buildLib() { ...external ]) } - const bundle = await rollup(rollupConfig) await Promise.all( writeOptions.map(option => bundle.write(option)) ) + + // dts + if (dts !== false) { + const rollupDtsConfig = { + input, + plugins: [nodeExternals(), dtsPlugin], + external: [...externals, ...external] + } + const writeDtsOptions: OutputOptions[] = [ + { + file: resolve( + PACKAGE, + name, + 'lib', + fn.replace(/\.ts$/, '.d.ts') + ), + format: 'es' + } + ] + const dtsBundle = await rollup(rollupDtsConfig) + await Promise.all([ + writeDtsOptions.map(option => dtsBundle.write(option)) + ]) + } } } )