Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/dev/scripts/polkadot-dev-build-ts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ function findFiles (buildDir, extra = '', exclude = []) {
.readdirSync(currDir)
.reduce((all, jsName) => {
const jsPath = `${extra}/${jsName}`;
const thisPath = path.join(buildDir, jsPath);
const fullPathEsm = path.join(buildDir, jsPath);
const toDelete = (
// no test paths
thisPath.includes('/test/') ||
jsPath.includes('/test/') ||
// // no tests
['.manual.', '.spec.', '.test.'].some((t) => jsName.includes(t)) ||
// no .d.ts compiled outputs
Expand All @@ -310,13 +310,13 @@ function findFiles (buildDir, extra = '', exclude = []) {
)
);

if (fs.statSync(thisPath).isDirectory()) {
if (fs.statSync(fullPathEsm).isDirectory()) {
findFiles(buildDir, jsPath).forEach((entry) => all.push(entry));
} else if (toDelete) {
const cjsPath = path.join(`${buildDir}-cjs`, jsPath);
const fullPathCjs = path.join(`${buildDir}-cjs`, jsPath);

fs.unlinkSync(thisPath);
fs.existsSync(cjsPath) && fs.unlinkSync(cjsPath);
fs.unlinkSync(fullPathEsm);
fs.existsSync(fullPathCjs) && fs.unlinkSync(fullPathCjs);
} else {
if (!exclude.some((e) => jsName === e)) {
// this is not mapped to a compiled .js file (where we have dual esm/cjs mappings)
Expand Down