From 2071592d016ad06eb17ea505b5f242eece855870 Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Wed, 23 Oct 2024 11:11:37 +0200 Subject: [PATCH] chore: fix build (#2504) * chore: fix build * fix esm import --- package.json | 5 ++- scripts/test-esm.mjs | 100 +++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/package.json b/package.json index eabb0f7a0a..03e369005a 100644 --- a/package.json +++ b/package.json @@ -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}\"", @@ -90,5 +90,6 @@ "lint-staged": { "*.ts": "eslint", "*{js,json,css,md,ts,tsx}": "prettier --write" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/scripts/test-esm.mjs b/scripts/test-esm.mjs index f6edd0eb00..4f231b8880 100644 --- a/scripts/test-esm.mjs +++ b/scripts/test-esm.mjs @@ -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); +});