Skip to content

Commit

Permalink
fix: d.ts does not copy in babel mode (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Jun 25, 2019
1 parent cc99bb5 commit 7df67e7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/father-build/src/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,24 @@ export default async function(opts: IBabelOpts) {
function createStream(src) {
const tsConfig = getTSConfig();
const babelTransformRegexp = disableTypeCheck ? /\.(t|j)sx?$/ : /\.jsx?$/;

function isTsFile(path) {
return /\.tsx?$/.test(path) && !path.endsWith('.d.ts');
}

function isTransform(path) {
return babelTransformRegexp.test(path) && !path.endsWith('.d.ts');
}

return vfs
.src(src, {
allowEmpty: true,
base: srcPath,
})
.pipe(gulpIf(f => !disableTypeCheck && /\.tsx?$/.test(f.path), gulpTs(tsConfig)))
.pipe(gulpIf(f => !disableTypeCheck && isTsFile(f.path), gulpTs(tsConfig)))
.pipe(
gulpIf(
f => babelTransformRegexp.test(f.path),
f => isTransform(f.path),
through.obj((file, env, cb) => {
try {
file.contents = Buffer.from(
Expand All @@ -130,7 +139,6 @@ export default async function(opts: IBabelOpts) {
join(srcPath, '**/*'),
`!${join(srcPath, '**/fixtures/**/*')}`,
`!${join(srcPath, '**/*.mdx')}`,
`!${join(srcPath, '**/*.d.ts')}`,
`!${join(srcPath, '**/*.+(test|e2e|spec).+(js|jsx|ts|tsx)')}`,
]).on('end', () => {
if (watch) {
Expand Down

0 comments on commit 7df67e7

Please sign in to comment.