Skip to content

Commit

Permalink
chore: fix build (#2504)
Browse files Browse the repository at this point in the history
* chore: fix build

* fix esm import
  • Loading branch information
n1ru4l authored Oct 23, 2024
1 parent 0c72ee4 commit 2071592
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 52 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ts:check": "tsc --project tsconfig.json --noEmit",
"ci:lint": "eslint \"packages/**/*.{js,jsx,ts,tsx}\" --output-file eslint_report.json --format json",
"build": "tsc --project tsconfig.json && bob build",
"test": "jest",
"test": "jest --config jest.config.base.js",
"prerelease": "yarn build",
"release": "changeset publish",
"format": "prettier --cache --ignore-path .gitignore --ignore-path .prettierignore --check --write \"{packages,website}/**/*.{js,jsx,json,css,md,mdx,ts,tsx}\"",
Expand Down Expand Up @@ -90,5 +90,6 @@
"lint-staged": {
"*.ts": "eslint",
"*{js,json,css,md,ts,tsx}": "prettier --write"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
100 changes: 50 additions & 50 deletions scripts/test-esm.mjs
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
import globby from 'globby';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import chalk from 'chalk';

async function main() {
const mjsFiles = await globby(['../packages/*/dist/*.mjs'], {
cwd: dirname(fileURLToPath(import.meta.url)),
});

const ok = [];
const fail = [];

let i = 0;
await Promise.all(
mjsFiles.map((mjsFile) => {
const mjsPath = `./${mjsFile}`;
return import(mjsPath)
.then(() => {
ok.push(mjsPath);
})
.catch((err) => {
const color = i++ % 2 === 0 ? chalk.magenta : chalk.red;
console.error(color('\n\n-----\n' + i + '\n'));
console.error(mjsPath, err);
console.error(color('\n-----\n\n'));
fail.push(mjsPath);
});
})
);
ok.length && console.log(chalk.blue(`${ok.length} OK: ${ok.join(' | ')}`));
fail.length &&
console.error(chalk.red(`${fail.length} Fail: ${fail.join(' | ')}`));

if (fail.length) {
console.error('\nFAILED');
process.exit(1);
} else if (ok.length) {
console.error('\nOK');
process.exit(0);
} else {
console.error('No files analyzed!');
process.exit(1);
}
}

main().catch((err) => {
console.error(err);
process.exit(1);
});
import { globby } from 'globby';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import chalk from 'chalk';

async function main() {
const mjsFiles = await globby(['../packages/*/dist/*.mjs'], {
cwd: dirname(fileURLToPath(import.meta.url)),
});

const ok = [];
const fail = [];

let i = 0;
await Promise.all(
mjsFiles.map((mjsFile) => {
const mjsPath = `./${mjsFile}`;
return import(mjsPath)
.then(() => {
ok.push(mjsPath);
})
.catch((err) => {
const color = i++ % 2 === 0 ? chalk.magenta : chalk.red;
console.error(color('\n\n-----\n' + i + '\n'));
console.error(mjsPath, err);
console.error(color('\n-----\n\n'));
fail.push(mjsPath);
});
})
);
ok.length && console.log(chalk.blue(`${ok.length} OK: ${ok.join(' | ')}`));
fail.length &&
console.error(chalk.red(`${fail.length} Fail: ${fail.join(' | ')}`));

if (fail.length) {
console.error('\nFAILED');
process.exit(1);
} else if (ok.length) {
console.error('\nOK');
process.exit(0);
} else {
console.error('No files analyzed!');
process.exit(1);
}
}

main().catch((err) => {
console.error(err);
process.exit(1);
});

0 comments on commit 2071592

Please sign in to comment.