tachybase_todo/packages/core/build/src/buildDeclaration.ts
jack zhang 08c5383bee
refactor: build tools (#2374)
* refactor: core/build and cli/build.js

* fix: build

* fix: bug

* fix: replaceAll to replace

* fix: node version check

* fix: add require check

* fix: esbuild other ext

* fix: process json

* fix: exlude jsx-runtime

* feat: split chunk

* fix: minify plugin client bundle

* fix: compatibility

* fix: support import()

* feat: update docs

* fix: server deps

* feat: demo

* fix: remove cjs treeshake

* fix: local error

* fix: bug

* fix: lazy load

* fix: rewrites

* fix: remove dynamic import  function

* feat: doc demo

* fix: codesanbox vite template

* fix: codesanbox demo

* fix: hide stackblitz

* fix: revert rspack

* fix: test bug

* fix: delete console

* fix: import dayjs locale

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
2023-09-03 10:59:33 +08:00

34 lines
1.2 KiB
TypeScript

import gulp from 'gulp';
import path from 'path';
import fs from 'fs';
import gulpTs from 'gulp-typescript';
import { ROOT_PATH } from './constant';
export const buildDeclaration = (cwd: string, targetDir: string) => {
return new Promise((resolve, reject) => {
const srcPath = path.join(cwd, 'src');
const targetPath = path.join(cwd, targetDir);
const tsConfig = gulpTs.createProject(path.join(ROOT_PATH, 'tsconfig.json'));
delete tsConfig.config.compilerOptions.paths;
const patterns = [
path.join(srcPath, '**/*.{ts,tsx}'),
`!${path.join(srcPath, '**/fixtures{,/**}')}`,
`!${path.join(srcPath, '**/demos{,/**}')}`,
`!${path.join(srcPath, '**/__test__{,/**}')}`,
`!${path.join(srcPath, '**/__tests__{,/**}')}`,
`!${path.join(srcPath, '**/*.mdx')}`,
`!${path.join(srcPath, '**/*.md')}`,
`!${path.join(srcPath, '**/*.+(test|e2e|spec).+(js|jsx|ts|tsx)')}`,
`!${path.join(srcPath, '**/tsconfig{,.*}.json')}`,
`!${path.join(srcPath, '.umi{,-production,-test}{,/**}')}`,
];
gulp
.src(patterns, { base: srcPath, allowEmpty: true })
.pipe(gulpTs(tsConfig.config.compilerOptions))
.dts.pipe(gulp.dest(targetPath))
.on('end', resolve)
.on('error', reject);
});
};