diff --git a/packages/tokens/gulpfile.ts b/packages/tokens/gulpfile.ts index b078eac8604e9..522a4847837b5 100644 --- a/packages/tokens/gulpfile.ts +++ b/packages/tokens/gulpfile.ts @@ -1,57 +1,46 @@ import path from 'path' -import gulp from 'gulp' +import { src, dest, parallel, series } from 'gulp' import ts from 'gulp-typescript' -import { buildOutput } from '../../build/utils/paths' +import { epOutput, projRoot } from '../../build/utils/paths' import rewriter from '../../build/gulp-rewriter' - -export const esm = './es' -export const cjs = './lib' -const tsProject = ts.createProject('tsconfig.json') - -const inputs = [ - './*.ts', - '!./node_modules', - '!./gulpfile.ts', - '!./__tests__/*.ts', -] - -function compileEsm() { - return gulp - .src(inputs) - .pipe(tsProject()) - .pipe(rewriter('..')) - .pipe(gulp.dest(esm)) +import { buildConfig } from '../../build/info' +import { withTaskName } from '../../build/utils/gulp' + +import type { Module } from '../../build/info' + +export const buildTokens = (module: Module) => { + const tsConfig = path.resolve(projRoot, 'tsconfig.json') + const inputs = [ + './*.ts', + '!./node_modules', + '!./gulpfile.ts', + '!./__tests__/*.ts', + path.resolve(projRoot, 'typings', 'vue-shim.d.ts'), + ] + const config = buildConfig[module] + return withTaskName(`buildTokens:${module}`, () => + src(inputs) + .pipe( + ts.createProject(tsConfig, { + module: config.module, + strict: false, + })() + ) + .pipe(rewriter('..')) + .pipe(dest(path.resolve(__dirname, config.output.name))) + ) } -function compileCjs() { - return gulp - .src(inputs) - .pipe( - ts.createProject('tsconfig.json', { - module: 'commonjs', - })() +const copyTokens = (module: Module) => { + const config = buildConfig[module] + return withTaskName(`copyTokens:${module}`, () => { + return src(`${path.resolve(__dirname, config.output.name)}/**`).pipe( + dest(path.resolve(epOutput, config.output.name, 'tokens')) ) - .pipe(rewriter('..')) - .pipe(gulp.dest(cjs)) + }) } -const distBundle = path.resolve(buildOutput, './element-plus') - -/** - * copy from packages/hooks/lib to dist/hooks - */ -function copyEsm() { - return gulp - .src(`${esm}/**`) - .pipe(gulp.dest(path.resolve(distBundle, './es/tokens'))) -} - -function copyCjs() { - return gulp - .src(`${cjs}/**`) - .pipe(gulp.dest(path.resolve(distBundle, './lib/tokens'))) -} - -export const build = gulp.series(compileEsm, compileCjs, copyEsm, copyCjs) - -export default build +export default parallel( + series(buildTokens('cjs'), copyTokens('cjs')), + series(buildTokens('esm'), copyTokens('esm')) +) diff --git a/packages/tokens/package.json b/packages/tokens/package.json index 2a9e9d6d13420..82cdbb68e25d7 100644 --- a/packages/tokens/package.json +++ b/packages/tokens/package.json @@ -7,7 +7,7 @@ }, "scripts": { "clean": "rimraf lib", - "build": "gulp build" + "build": "gulp" }, "main": "index.ts", "module": "index.ts", diff --git a/packages/tokens/tsconfig.json b/packages/tokens/tsconfig.json deleted file mode 100644 index ff3d601b3d417..0000000000000 --- a/packages/tokens/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true, - "rootDir": ".", - "declaration": true, - "lib": ["ES2020", "DOM"], - "skipLibCheck": true, - "target": "es6", - "moduleResolution": "node" - } -} diff --git a/tsconfig.json b/tsconfig.json index eb7b943a66239..539da6defcf30 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, - "strict": true + "strict": true, + "skipLibCheck": true }, "exclude": [ "node_modules", diff --git a/typings/vue-shim.d.ts b/typings/vue-shim.d.ts index 2bdbaebcacc46..8337a1d5fc776 100644 --- a/typings/vue-shim.d.ts +++ b/typings/vue-shim.d.ts @@ -1,6 +1,6 @@ -/* eslint-disable */ declare module '*.vue' { - import { DefineComponent } from 'vue' + import type { DefineComponent } from 'vue' + // eslint-disable-next-line @typescript-eslint/ban-types const component: DefineComponent<{}, {}, any> export default component }