diff --git a/TokenTrackerWin/scripts/bundle-node.ps1 b/TokenTrackerWin/scripts/bundle-node.ps1 index 09674b0ea..7c084a4fc 100644 --- a/TokenTrackerWin/scripts/bundle-node.ps1 +++ b/TokenTrackerWin/scripts/bundle-node.ps1 @@ -143,6 +143,12 @@ Write-Host 'Installing production dependencies...' Push-Location $ttDir try { & npm install --omit=dev --no-optional --ignore-scripts | Out-Null + & npm rebuild '@mongodb-js/zstd' | Out-Null + if ($LASTEXITCODE -ne 0) { Write-Error 'Failed to build @mongodb-js/zstd' } + + $zstdModule = Join-Path $ttDir 'node_modules\@mongodb-js\zstd' + & (Join-Path $EmbedDir 'node.exe') -e 'require(process.argv[1])' $zstdModule + if ($LASTEXITCODE -ne 0) { Write-Error 'Bundled @mongodb-js/zstd failed to load' } } finally { Pop-Location } diff --git a/test/release-windows-workflow.test.js b/test/release-windows-workflow.test.js index 67fbca612..806d34b9c 100644 --- a/test/release-windows-workflow.test.js +++ b/test/release-windows-workflow.test.js @@ -15,6 +15,14 @@ function loadWorkflow() { return fs.readFileSync(WORKFLOW_PATH, "utf8"); } +const BUNDLE_SCRIPT_PATH = path.join( + __dirname, + "..", + "TokenTrackerWin", + "scripts", + "bundle-node.ps1" +); + test("release-windows workflow file exists", () => { assert.ok(fs.existsSync(WORKFLOW_PATH)); }); @@ -66,6 +74,13 @@ test("workflow bundles EmbeddedServer via bundle-node.ps1", () => { assert.ok(content.includes("bundle-node.ps1")); }); +test("Windows bundle rebuilds and loads the zstd native dependency", () => { + const content = fs.readFileSync(BUNDLE_SCRIPT_PATH, "utf8"); + assert.ok(content.includes("npm rebuild '@mongodb-js/zstd'")); + assert.ok(content.includes("require(process.argv[1])")); + assert.ok(content.includes("Bundled @mongodb-js/zstd failed to load")); +}); + test("workflow publishes a self-contained win-x64 build", () => { const content = loadWorkflow(); assert.ok(content.includes("dotnet publish"));