Skip to content

Commit a2ec193

Browse files
committedSep 11, 2021
fix(tsbb): Fix copyFiles issue.
1 parent efd8ebc commit a2ec193

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed
 

‎packages/tsbb/src/utils/compile.ts

+26-20
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,34 @@ export async function compile(
2828
const dirToFiles = await recursiveReaddirFiles(path.dirname(entry), {
2929
exclude: /(tsconfig.json|.d.ts|.(test|spec).(ts|tsx|js|jsx))$/,
3030
});
31-
if (!disableBabel) {
32-
await Promise.all(
33-
dirToFiles.map(async (item) => {
34-
if (cjs) {
35-
const cjsPath = item.path.replace(entryDir, cjs);
36-
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)'])) {
37-
transform(item.path, { entryDir, cjs, ...other });
38-
} else {
39-
copyFiles(item.path, cjsPath);
40-
}
31+
await Promise.all(
32+
dirToFiles.map(async (item) => {
33+
if (cjs) {
34+
const cjsPath = item.path.replace(entryDir, cjs);
35+
if (
36+
!disableBabel &&
37+
isMatch(item.path, ['**/*.[jt]s?(x)']) &&
38+
!isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)'])
39+
) {
40+
transform(item.path, { entryDir, cjs, ...other });
41+
} else {
42+
copyFiles(item.path, cjsPath);
4143
}
42-
if (esm) {
43-
const esmPath = item.path.replace(entryDir, esm);
44-
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)'])) {
45-
transform(item.path, { entryDir, esm, ...other });
46-
} else {
47-
copyFiles(item.path, esmPath);
48-
}
44+
}
45+
if (esm) {
46+
const esmPath = item.path.replace(entryDir, esm);
47+
if (
48+
!disableBabel &&
49+
isMatch(item.path, ['**/*.[jt]s?(x)']) &&
50+
!isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)'])
51+
) {
52+
transform(item.path, { entryDir, esm, ...other });
53+
} else {
54+
copyFiles(item.path, esmPath);
4955
}
50-
}),
51-
);
52-
}
56+
}
57+
}),
58+
);
5359

5460
// Create a Program with an in-memory emit
5561
const createdFiles: Record<string, string> = {};

0 commit comments

Comments
 (0)
Please sign in to comment.