From dc165f3aa3e9beb9bab55141b7663c38627f75b4 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:41:27 -0700 Subject: [PATCH 1/3] Add failing test --- scripts/browserIntegrationTest.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/browserIntegrationTest.mjs b/scripts/browserIntegrationTest.mjs index f1fab43f2213c..7b3021f979350 100644 --- a/scripts/browserIntegrationTest.mjs +++ b/scripts/browserIntegrationTest.mjs @@ -29,6 +29,7 @@ for (const browserType of browsers) { await page.setContent(` + `); From 1f5f17adfbba24595d6e9d741d5a57a7e2b359a9 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:52:27 -0700 Subject: [PATCH 2/3] Fix global when typescript.js loaded as script --- Herebyfile.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Herebyfile.mjs b/Herebyfile.mjs index 8447834a6338a..c72eeb1a214bf 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -216,7 +216,7 @@ function createBundler(entrypoint, outfile, taskOptions = {}) { // Monaco bundles us as ESM by wrapping our code with something that defines module.exports // but then does not use it, instead using the `ts` variable. Ensure that if we think we're CJS // that we still set `ts` to the module.exports object. - options.footer = { js: `})(typeof module !== "undefined" && module.exports ? module : { exports: ts });\nif (typeof module !== "undefined" && module.exports) { ts = module.exports; }` }; + options.footer = { js: `})({ get exports() { return ts }, set exports(v) { ts = v; if (typeof module !== "undefined" && module.exports) { module.exports = v } } })` }; // esbuild converts calls to "require" to "__require"; this function // calls the real require if it exists, or throws if it does not (rather than From f26f1f0dddf3a6606db2446b065ba5c5b78028b0 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:25:13 -0700 Subject: [PATCH 3/3] Formatting consistency --- Herebyfile.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Herebyfile.mjs b/Herebyfile.mjs index c72eeb1a214bf..dac359b24de61 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -216,7 +216,7 @@ function createBundler(entrypoint, outfile, taskOptions = {}) { // Monaco bundles us as ESM by wrapping our code with something that defines module.exports // but then does not use it, instead using the `ts` variable. Ensure that if we think we're CJS // that we still set `ts` to the module.exports object. - options.footer = { js: `})({ get exports() { return ts }, set exports(v) { ts = v; if (typeof module !== "undefined" && module.exports) { module.exports = v } } })` }; + options.footer = { js: `})({ get exports() { return ts; }, set exports(v) { ts = v; if (typeof module !== "undefined" && module.exports) { module.exports = v; } } })` }; // esbuild converts calls to "require" to "__require"; this function // calls the real require if it exists, or throws if it does not (rather than