ttsc 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.patchCreateProgram = exports.addDiagnosticFactory = exports.transformerErrors = void 0;
35
35
  var path_1 = require("path");
36
+ var ts = require("typescript");
36
37
  var PluginCreator_1 = require("./PluginCreator");
38
+ var _a = ts.version.split('.').map(function (str) { return Number(str); }), major = _a[0], minor = _a[1];
37
39
  exports.transformerErrors = new WeakMap();
38
40
  function addDiagnosticFactory(program) {
39
41
  return function (diag) {
@@ -159,12 +161,19 @@ function injectionShadowedValues(target) {
159
161
  return path.length > extension.length && path.endsWith(extension);
160
162
  }
161
163
  try {
162
- var originTranspileModule = target.transpileModule
163
- .toString()
164
- .replace(/(?<!function)\s([a-z][A-Za-z0-9]+)\(/g, ' target.$1(')
165
- .replace('hasProperty', 'target.hasProperty')
166
- .replace(/Debug\./g, 'target.')
167
- .replace('transpileOptionValueCompilerOptions', 'target.transpileOptionValueCompilerOptions');
164
+ var originTranspileModule = major >= 5
165
+ ? target.transpileModule
166
+ .toString()
167
+ .replace(/(?<!function)\s([a-z][A-Za-z0-9]+)\(/g, ' target.$1(')
168
+ .replace('hasProperty', 'target.hasProperty')
169
+ .replace(/Debug\./g, 'target.')
170
+ .replace('transpileOptionValueCompilerOptions', 'target.transpileOptionValueCompilerOptions')
171
+ : target.transpileModule
172
+ .toString()
173
+ .replace(/(?<!function)\s([a-z][A-Za-z0-9]+)\(/g, ' target.$1(')
174
+ .replace(/ts\./g, 'target.')
175
+ .replace(/Debug\./g, 'target.')
176
+ .replace(/target\.target\./g, 'target.');
168
177
  var __ = target.transpileModule, _target = __rest(target, ["transpileModule"]);
169
178
  _target.transpileModule = eval('(' + originTranspileModule + ')');
170
179
  return _target;
package/lib/tsc.js CHANGED
@@ -10,9 +10,9 @@ var tscFileName = resolve.sync('typescript/lib/tsc', { basedir: process.cwd() })
10
10
  var _a = ts.version.split('.').map(function (str) { return Number(str); }), major = _a[0], minor = _a[1];
11
11
  var commandLineTsCode = fs
12
12
  .readFileSync(tscFileName, 'utf8')
13
- .replace(major >= 4 && minor >= 9
13
+ .replace(major == 4 && minor >= 9
14
14
  ? /^[\s\S]+(\(function \(ts\) {\s+var StatisticType;[\s\S]+)$/
15
- : /^[\s\S]+(\(function \(ts\) \{\s+function countLines[\s\S]+)$/, '$1');
15
+ : /^[\s\S]+(\(function \(ts\) {\s+function countLines[\s\S]+)$/, '$1');
16
16
  if (major >= 5) {
17
17
  commandLineTsCode = commandLineTsCode.replace(/\= createProgram\(/g, '= ts.createProgram(');
18
18
  }
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "prettier": "npx prettier --config .prettierrc.js --check .",
15
15
  "prettier:fix": "npx prettier --config .prettierrc.js --write ."
16
16
  },
17
- "version": "0.1.0",
17
+ "version": "0.3.0",
18
18
  "description": "Over TypeScript tool to use custom transformers in the tsconfig.json",
19
19
  "main": "lib/typescript.js",
20
20
  "files": [