From 3fea6d7537375ea4c901beac0b7521b47b6c0c1e Mon Sep 17 00:00:00 2001 From: mingxuanzhang Date: Tue, 1 Oct 2024 17:36:35 -0700 Subject: [PATCH] ci: add check for dependencies that need externalizing during bundle --- .github/workflows/bundle.yml | 5 ++--- scripts/bundleWithCheck.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 scripts/bundleWithCheck.js diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml index 6df4bd2f3..6b134c64c 100644 --- a/.github/workflows/bundle.yml +++ b/.github/workflows/bundle.yml @@ -28,10 +28,9 @@ jobs: - name: Update for Bundling run: | node scripts/updateForBundling.js - - name: Generate Bundle + - name: Generate Bundle and Check if there is any dependency that needs to be externalized and is not in the whitelist. run: | - yarn build - node scripts/build.js + node scripts/bundleWithCheck.js - name: Post Bundling Update run: | node scripts/postBundlingUpdate.js diff --git a/scripts/bundleWithCheck.js b/scripts/bundleWithCheck.js new file mode 100644 index 000000000..46e62074c --- /dev/null +++ b/scripts/bundleWithCheck.js @@ -0,0 +1,17 @@ +const { exec } = require('child_process'); + +const commandToRun = 'yarn build && node ./scripts/build.js'; + +// Run the command +exec(commandToRun, (error, stdout, stderr) => { + // Combine stdout and stderr to check the entire output + const output = `${stdout}\n${stderr}`; + console.log('aaaa', output); + // Check if the output contains the error string of esbuild + if (output.includes('[require-resolve-not-external]')) { + console.error('Error: A dependency that has to be externalized in esbuild process is found. Please resolve it!'); + process.exit(1); // Exit with an error code + } else { + process.exit(0); // Exit with success code + } +});