Skip to content

Commit 505e3aa

Browse files
author
cevek
committed
Fix global __assign and other functions for tsc
1 parent 1db6195 commit 505e3aa

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/ttypescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"ttsc": "./bin/tsc",
55
"ttsserver": "./bin/tsserver"
66
},
7-
"version": "1.5.11",
7+
"version": "1.5.12",
88
"description": "Over TypeScript tool to use custom transformers in the tsconfig.json",
99
"main": "lib/typescript.js",
1010
"files": [

packages/ttypescript/src/tsc.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ const ts = loadTypeScript('typescript', { folder: process.cwd(), forceConfigLoad
88
const tscFileName = resolve.sync('typescript/lib/tsc', { basedir: process.cwd() });
99
const commandLineTsCode = fs
1010
.readFileSync(tscFileName, 'utf8')
11-
.replace(/^[\s\S]+(\(function \(ts\) \{\s+function countLines[\s\S]+)$/, '$1')
11+
.replace(/^[\s\S]+(\(function \(ts\) \{\s+function countLines[\s\S]+)$/, '$1');
1212

13-
runInThisContext(`(function (exports, require, module, __filename, __dirname, ts) {${commandLineTsCode}\n});`, {
14-
filename: tscFileName,
15-
lineOffset: 0,
16-
displayErrors: true,
17-
}).call(ts, ts, require, { exports: ts }, tscFileName, dirname(tscFileName), ts);
13+
const globalCode = (fs.readFileSync(tscFileName, 'utf8').match(/^([\s\S]*?)var ts;/) || ['', ''])[1];
14+
runInThisContext(
15+
`(function (exports, require, module, __filename, __dirname, ts) {${globalCode}${commandLineTsCode}\n});`,
16+
{
17+
filename: tscFileName,
18+
lineOffset: 0,
19+
displayErrors: true,
20+
}
21+
).call(ts, ts, require, { exports: ts }, tscFileName, dirname(tscFileName), ts);

0 commit comments

Comments
 (0)