Skip to content

Commit 5edb40e

Browse files
committed
Just make it a const, env var controlled for later use
1 parent 66b407b commit 5edb40e

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

Herebyfile.mjs

+1-7
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ async function runDtsBundler(entrypoint, output) {
175175
* @property {boolean} [exportIsTsObject]
176176
* @property {boolean} [treeShaking]
177177
* @property {boolean} [usePublicAPI]
178-
* @property {boolean} [tsgoCompat]
179178
* @property {() => void} [onWatchRebuild]
180179
*/
181180
function createBundler(entrypoint, outfile, taskOptions = {}) {
@@ -197,9 +196,6 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
197196
treeShaking: taskOptions.treeShaking,
198197
packages: "external",
199198
logLevel: "warning",
200-
define: {
201-
__TSGO_COMPAT__: taskOptions.tsgoCompat ? "true" : "false",
202-
},
203199
// legalComments: "none", // If we add copyright headers to the source files, uncomment.
204200
};
205201

@@ -236,8 +232,7 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
236232
const require = "require";
237233
const fakeName = "Q".repeat(require.length);
238234
const fakeNameRegExp = new RegExp(fakeName, "g");
239-
options.define = options.define || {};
240-
options.define[require] = fakeName;
235+
options.define = { [require]: fakeName };
241236

242237
// For historical reasons, TypeScript does not set __esModule. Hack esbuild's __toCommonJS to be a noop.
243238
// We reference `__copyProps` to ensure the final bundle doesn't have any unreferenced code.
@@ -546,7 +541,6 @@ const { main: tests, watch: watchTests } = entrypointBuildTask({
546541
output: testRunner,
547542
mainDeps: [generateLibs],
548543
bundlerOptions: {
549-
tsgoCompat: true,
550544
// Ensure we never drop any dead code, which might be helpful while debugging.
551545
treeShaking: false,
552546
onWatchRebuild() {

src/compiler/checker.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
__String,
3+
__TSGO_COMPAT__,
34
AccessExpression,
45
AccessFlags,
56
AccessorDeclaration,

src/compiler/corePublic.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ export const versionMajorMinor = "5.7";
55
/** The version of the TypeScript compiler release */
66
export const version: string = `${versionMajorMinor}.0-dev`;
77

8-
declare global {
9-
var __TSGO_COMPAT__: boolean | undefined; // eslint-disable-line no-var, @typescript-eslint/naming-convention
10-
}
8+
const tsgoCompatEnv = typeof process !== "undefined" && process.env ? process.env.TSGO_COMPAT : undefined;
119

12-
globalThis.__TSGO_COMPAT__ ??= false;
10+
/** @internal */
11+
export const __TSGO_COMPAT__: boolean = tsgoCompatEnv ? tsgoCompatEnv === "true" : true;
1312

1413
/**
1514
* Type of objects whose values are all of the same type.

0 commit comments

Comments
 (0)