Skip to content

Commit 02132e5

Browse files
TypeScript Botjakebailey
TypeScript Bot
andauthored
🤖 Pick PR #58895 (Fix global when typescript.js loade...) into release-5.5 (#58896)
Co-authored-by: Jake Bailey <[email protected]>
1 parent 45b1e3c commit 02132e5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Diff for: ‎Herebyfile.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
216216
// Monaco bundles us as ESM by wrapping our code with something that defines module.exports
217217
// but then does not use it, instead using the `ts` variable. Ensure that if we think we're CJS
218218
// that we still set `ts` to the module.exports object.
219-
options.footer = { js: `})(typeof module !== "undefined" && module.exports ? module : { exports: ts });\nif (typeof module !== "undefined" && module.exports) { ts = module.exports; }` };
219+
options.footer = { js: `})({ get exports() { return ts; }, set exports(v) { ts = v; if (typeof module !== "undefined" && module.exports) { module.exports = v; } } })` };
220220

221221
// esbuild converts calls to "require" to "__require"; this function
222222
// calls the real require if it exists, or throws if it does not (rather than

Diff for: ‎scripts/browserIntegrationTest.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ for (const browserType of browsers) {
2929
await page.setContent(`
3030
<html>
3131
<script>${readFileSync(join("built", "local", "typescript.js"), "utf8")}</script>
32+
<script>if (typeof ts.version !== "string") throw new Error("ts.version not set")</script>
3233
</html>
3334
`);
3435

0 commit comments

Comments
 (0)