fix(build): fix dts (#4741)

This commit is contained in:
nemo-shen 2022-01-11 09:14:28 +08:00 committed by GitHub
parent 639527add9
commit a8d6c351af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 20 deletions

View File

@ -7,6 +7,7 @@ const rename = require('gulp-rename');
const postcss = require('gulp-postcss');
const ts = require('gulp-typescript');
const util = require('util');
const merge2 = require('merge2');
const exec = util.promisify(require('child_process').exec);
const src = path.resolve(__dirname, '../packages');
@ -54,26 +55,31 @@ const lessCompiler = (dist) =>
const tsCompiler = (dist, config) =>
function compileTs() {
const tsProject = ts.createProject(config);
return tsProject
.src()
.pipe(tsProject())
.js.pipe(
insert.transform((contents, file) => {
if (dist === exampleDistDir && file.path.includes('/demo/')) {
const iconConfig = '@vant/icons/src/config';
contents = contents.replace(
iconConfig,
path.relative(
path.dirname(file.path),
`${exampleDistDir}/${iconConfig}`
)
);
}
return contents;
})
)
.pipe(gulp.dest(dist));
const tsProject = ts.createProject(config, {
declaration: true,
});
const tsResult = tsProject.src().pipe(tsProject());
return merge2(
tsResult.js
.pipe(
insert.transform((contents, file) => {
if (dist === exampleDistDir && file.path.includes('/demo/')) {
const iconConfig = '@vant/icons/src/config';
contents = contents.replace(
iconConfig,
path.relative(
path.dirname(file.path),
`${exampleDistDir}/${iconConfig}`
)
);
}
return contents;
})
)
.pipe(gulp.dest(dist)),
tsResult.dts.pipe(gulp.dest(dist))
);
};
const copier = (dist, ext) =>

View File

@ -54,6 +54,7 @@
"gulp-rename": "^2.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
"jest": "^27.3.1",
"merge2": "^1.4.1",
"miniprogram-api-typings": "^3.1.6",
"miniprogram-ci": "^1.6.1",
"miniprogram-simulate": "^1.4.2",

View File

@ -9364,6 +9364,11 @@ merge2@^1.2.3, merge2@^1.3.0:
resolved "https://registry.npm.taobao.org/merge2/download/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha1-Q2iJL4hekHRVpv19xVwMnUBJkK4=
merge2@^1.4.1:
version "1.4.1"
resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
micromark@~2.11.0:
version "2.11.4"
resolved "https://registry.npm.taobao.org/micromark/download/micromark-2.11.4.tgz#d13436138eea826383e822449c9a5c50ee44665a"