diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 0313eedc4e1..4a3b9af4257 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -472,7 +472,7 @@ namespace ts { */ function isFileAffectingGlobalScope(sourceFile: SourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** diff --git a/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js index 9496bd575b8..d08f1b6c519 100644 --- a/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js +++ b/tests/baselines/reference/tsbuild/javascriptProjectEmit/initial-build/loads-js-based-projects-and-emits-them-correctly.js @@ -151,7 +151,7 @@ module.exports = {}; "../../src/common/nominal.js": { "version": "-9003723607-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};\n", "signature": "-15964609857-export type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n", - "affectsGlobalScope": true + "affectsGlobalScope": false } }, "options": {