From 53f6048ef26ef822006b109a9dba892133abb8da Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 5 May 2021 19:26:48 -0700 Subject: [PATCH] cleanup after landing #1238 --- CHANGELOG.md | 6 ++++++ scripts/deno-tests.js | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e8a11a7916..947067228a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +* Allow esbuild to be restarted in Deno ([#1238](https://github.com/evanw/esbuild/pull/1238)) + + The esbuild API for [Deno](https://deno.land) has an extra function called `stop()` that doesn't exist in esbuild's API for node. This is because Deno doesn't provide a way to stop esbuild automatically, so calling `stop()` is required to allow Deno to exit. However, once stopped the esbuild API could not be restarted. + + With this release, you can now continue to use esbuild after calling `stop()`. This will restart esbuild's API and means that you will need to call `stop()` again for Deno to be able to exit. This feature was contributed by [@lucacasonato](https://github.com/lucacasonato). + * Fix code generation with `declare` class fields ([#1242](https://github.com/evanw/esbuild/issues/1242)) This fixes a bug with TypeScript code that uses `declare` on a class field and your `tsconfig.json` file has `"useDefineForClassFields": true`. Fields marked as `declare` should not be defined in the generated code, but they were incorrectly being declared as `undefined`. These fields are now correctly omitted from the generated code. diff --git a/scripts/deno-tests.js b/scripts/deno-tests.js index f080c7f90f7..90dd62fe945 100644 --- a/scripts/deno-tests.js +++ b/scripts/deno-tests.js @@ -4,6 +4,7 @@ import * as path from 'https://deno.land/std@0.95.0/path/mod.ts' import * as asserts from 'https://deno.land/std@0.95.0/testing/asserts.ts' const rootTestDir = path.join(path.dirname(path.fromFileUrl(import.meta.url)), '.deno-tests') +let testDidFail = false try { Deno.removeSync(rootTestDir, { recursive: true }) @@ -17,20 +18,28 @@ function test(name, fn) { await Deno.mkdir(testDir, { recursive: true }) try { await fn({ testDir }) - } finally { await Deno.remove(testDir, { recursive: true }).catch(() => null) + } catch (e) { + testDidFail = true + throw e + } finally { esbuild.stop() } }) } -window.addEventListener("unload", () => { - try { - Deno.removeSync(rootTestDir, { recursive: true }) - } catch { - // root test dir possibly already removed, so ignore +window.addEventListener("unload", (e) => { + if (testDidFail) { + console.error(`❌ deno tests failed`) + } else { + console.log(`✅ deno tests passed`) + try { + Deno.removeSync(rootTestDir, { recursive: true }) + } catch { + // root test dir possibly already removed, so ignore + } } -}) +}) test("basicBuild", async ({ testDir }) => { const input = path.join(testDir, 'in.ts')