ts-swc-transform 1.7.7 → 1.7.9
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.
- package/dist/cjs/workers/transformDirectory.js +43 -2
- package/dist/cjs/workers/transformDirectory.js.map +1 -1
- package/dist/cjs/workers/transformFile.js +43 -2
- package/dist/cjs/workers/transformFile.js.map +1 -1
- package/dist/cjs/workers/transformSync.js.map +1 -1
- package/dist/cjs/workers/transformTypes.js +43 -2
- package/dist/cjs/workers/transformTypes.js.map +1 -1
- package/dist/esm/workers/transformDirectory.mjs +1 -1
- package/dist/esm/workers/transformDirectory.mjs.map +1 -1
- package/dist/esm/workers/transformFile.mjs +1 -1
- package/dist/esm/workers/transformFile.mjs.map +1 -1
- package/dist/esm/workers/transformSync.mjs.map +1 -1
- package/dist/esm/workers/transformTypes.mjs +1 -1
- package/dist/esm/workers/transformTypes.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
12
|
var _fsiterator = /*#__PURE__*/ _interop_require_default(require("fs-iterator"));
|
|
13
|
-
var _gettsconfigcompat = /*#__PURE__*/
|
|
13
|
+
var _gettsconfigcompat = /*#__PURE__*/ _interop_require_wildcard(require("get-tsconfig-compat"));
|
|
14
14
|
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
15
15
|
var _rimraf2 = /*#__PURE__*/ _interop_require_default(require("rimraf2"));
|
|
16
16
|
var _constants = require("../constants.js");
|
|
@@ -34,6 +34,47 @@ function _interop_require_default(obj) {
|
|
|
34
34
|
default: obj
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
38
|
+
if (typeof WeakMap !== "function") return null;
|
|
39
|
+
var cacheBabelInterop = new WeakMap();
|
|
40
|
+
var cacheNodeInterop = new WeakMap();
|
|
41
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
42
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
43
|
+
})(nodeInterop);
|
|
44
|
+
}
|
|
45
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
46
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
50
|
+
return {
|
|
51
|
+
default: obj
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
55
|
+
if (cache && cache.has(obj)) {
|
|
56
|
+
return cache.get(obj);
|
|
57
|
+
}
|
|
58
|
+
var newObj = {
|
|
59
|
+
__proto__: null
|
|
60
|
+
};
|
|
61
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
62
|
+
for(var key in obj){
|
|
63
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
64
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
65
|
+
if (desc && (desc.get || desc.set)) {
|
|
66
|
+
Object.defineProperty(newObj, key, desc);
|
|
67
|
+
} else {
|
|
68
|
+
newObj[key] = obj[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
newObj.default = obj;
|
|
73
|
+
if (cache) {
|
|
74
|
+
cache.set(obj, newObj);
|
|
75
|
+
}
|
|
76
|
+
return newObj;
|
|
77
|
+
}
|
|
37
78
|
function _object_spread(target) {
|
|
38
79
|
for(var i = 1; i < arguments.length; i++){
|
|
39
80
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -74,7 +115,7 @@ function _object_spread_props(target, source) {
|
|
|
74
115
|
return target;
|
|
75
116
|
}
|
|
76
117
|
function transformDirectoryWorker(src, dest, type, options, callback) {
|
|
77
|
-
var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.
|
|
118
|
+
var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.getTsconfig(src);
|
|
78
119
|
var matcher = (0, _createMatcher.default)(tsconfig);
|
|
79
120
|
(0, _rimraf2.default)(dest, {
|
|
80
121
|
disableGlob: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\nimport transformFile from './transformFile.js';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n\n options = { ...options, tsconfig };\n const queue = new Queue();\n entries.forEach((entry) => queue.defer(transformFile.bind(null, entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options)));\n queue.await(callback);\n }\n );\n });\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","getTS","getTsconfig","matcher","createMatcher","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","fullPath","typeFileRegEx","test","basename","SKIPS","indexOf","push","err","queue","Queue","defer","transformFile","bind","path","dirname","join","await"],"mappings":";;;;+BAUA;;;eAAwBA;;;2DAVP;iEACI;
|
|
1
|
+
{"version":3,"sources":["transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport * as getTS from 'get-tsconfig-compat';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\nimport transformFile from './transformFile.js';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n\n options = { ...options, tsconfig };\n const queue = new Queue();\n entries.forEach((entry) => queue.defer(transformFile.bind(null, entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options)));\n queue.await(callback);\n }\n );\n });\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","getTS","getTsconfig","matcher","createMatcher","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","fullPath","typeFileRegEx","test","basename","SKIPS","indexOf","push","err","queue","Queue","defer","transformFile","bind","path","dirname","join","await"],"mappings":";;;;+BAUA;;;eAAwBA;;;2DAVP;iEACI;yEACE;8DACL;8DACE;yBAEiB;oEACX;oEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEX,SAASA,yBAAyBC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACjF,IAAMC,WAAWF,QAAQE,QAAQ,GAAGF,QAAQE,QAAQ,GAAGC,mBAAMC,WAAW,CAACP;IACzE,IAAMQ,UAAUC,IAAAA,sBAAa,EAACJ;IAE9BK,IAAAA,gBAAO,EAACT,MAAM;QAAEU,aAAa;IAAK,GAAG;QACnC,IAAMC,UAAU,EAAE;QAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAACd;QAC9Ba,SAASE,OAAO,CACd,SAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAI,CAACV,QAAQQ,MAAMG,QAAQ,GAAG;YAC9B,IAAIC,wBAAa,CAACC,IAAI,CAACL,MAAMM,QAAQ,GAAG;YACxC,IAAIC,gBAAK,CAACC,OAAO,CAACR,MAAMM,QAAQ,KAAK,GAAG;YACxCV,QAAQa,IAAI,CAACT;QACf,GACA,SAACU;YACC,IAAIA,KAAK,OAAOtB,SAASsB;YAEzBvB,UAAU,wCAAKA;gBAASE,UAAAA;;YACxB,IAAMsB,QAAQ,IAAIC,gBAAK;YACvBhB,QAAQG,OAAO,CAAC,SAACC;uBAAUW,MAAME,KAAK,CAACC,sBAAa,CAACC,IAAI,CAAC,MAAMf,MAAMG,QAAQ,EAAEa,aAAI,CAACC,OAAO,CAACD,aAAI,CAACE,IAAI,CAACjC,MAAMe,MAAMgB,IAAI,IAAI9B,MAAMC;;YACjIwB,MAAMQ,KAAK,CAAC/B;QACd;IAEJ;AACF"}
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
12
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
13
|
var _calloncefn = /*#__PURE__*/ _interop_require_default(require("call-once-fn"));
|
|
14
|
-
var _gettsconfigcompat = /*#__PURE__*/
|
|
14
|
+
var _gettsconfigcompat = /*#__PURE__*/ _interop_require_wildcard(require("get-tsconfig-compat"));
|
|
15
15
|
var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
|
|
16
16
|
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
17
17
|
var _transformSync = /*#__PURE__*/ _interop_require_default(require("./transformSync.js"));
|
|
@@ -33,6 +33,47 @@ function _interop_require_default(obj) {
|
|
|
33
33
|
default: obj
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
37
|
+
if (typeof WeakMap !== "function") return null;
|
|
38
|
+
var cacheBabelInterop = new WeakMap();
|
|
39
|
+
var cacheNodeInterop = new WeakMap();
|
|
40
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
41
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
42
|
+
})(nodeInterop);
|
|
43
|
+
}
|
|
44
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
45
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
49
|
+
return {
|
|
50
|
+
default: obj
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
54
|
+
if (cache && cache.has(obj)) {
|
|
55
|
+
return cache.get(obj);
|
|
56
|
+
}
|
|
57
|
+
var newObj = {
|
|
58
|
+
__proto__: null
|
|
59
|
+
};
|
|
60
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
61
|
+
for(var key in obj){
|
|
62
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
63
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
64
|
+
if (desc && (desc.get || desc.set)) {
|
|
65
|
+
Object.defineProperty(newObj, key, desc);
|
|
66
|
+
} else {
|
|
67
|
+
newObj[key] = obj[key];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
newObj.default = obj;
|
|
72
|
+
if (cache) {
|
|
73
|
+
cache.set(obj, newObj);
|
|
74
|
+
}
|
|
75
|
+
return newObj;
|
|
76
|
+
}
|
|
36
77
|
function _object_spread(target) {
|
|
37
78
|
for(var i = 1; i < arguments.length; i++){
|
|
38
79
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -101,7 +142,7 @@ function transformFileWorker(src, dest, type, options, callback) {
|
|
|
101
142
|
if (err) return callback(err);
|
|
102
143
|
callback = (0, _calloncefn.default)(callback);
|
|
103
144
|
try {
|
|
104
|
-
var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.
|
|
145
|
+
var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.getTsconfig(src);
|
|
105
146
|
// overrides for cjs
|
|
106
147
|
if (type === 'cjs') {
|
|
107
148
|
tsconfig = _object_spread({}, tsconfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport once from 'call-once-fn';\nimport getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\n\nimport transformSync from './transformSync.js';\n\nconst matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nconst matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nconst regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`, 'g');\nconst regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\\\s*)?${matchingDeps};?|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`, 'g');\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nexport default function transformFileWorker(src, dest, type, options, callback) {\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.tsconfig = { ...(tsconfig.config || {}) };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'CommonJS';\n tsconfig.config.compilerOptions.target = 'ES5';\n }\n\n const basename = path.basename(src);\n transformSync(contents, basename, tsconfig, (err, output) => {\n if (err) return callback(err);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n"],"names":["transformFileWorker","matchingDeps","matchingName","regexCJS","RegExp","regexESM","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","dependency","match","ext","find","x","slice","length","matches","push","exec","reverse","index","start","indexOf","substring","interopClientDefaultExport","src","dest","type","options","callback","fs","readFile","err","contents","once","tsconfig","getTS","getTsconfig","config","compilerOptions","module","target","basename","path","transformSync","output","extname","destFilePath","join","replace","mkdirp","dirname","queue","Queue","defer","writeFile","bind","sourceMaps","map","await"],"mappings":";;;;+BAwCA;;;eAAwBA;;;yDAxCT;2DACE;iEACA;
|
|
1
|
+
{"version":3,"sources":["transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport once from 'call-once-fn';\nimport * as getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\n\nimport transformSync from './transformSync.js';\n\nconst matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nconst matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nconst regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`, 'g');\nconst regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\\\s*)?${matchingDeps};?|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`, 'g');\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nexport default function transformFileWorker(src, dest, type, options, callback) {\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.tsconfig = { ...(tsconfig.config || {}) };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'CommonJS';\n tsconfig.config.compilerOptions.target = 'ES5';\n }\n\n const basename = path.basename(src);\n transformSync(contents, basename, tsconfig, (err, output) => {\n if (err) return callback(err);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n"],"names":["transformFileWorker","matchingDeps","matchingName","regexCJS","RegExp","regexESM","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","dependency","match","ext","find","x","slice","length","matches","push","exec","reverse","index","start","indexOf","substring","interopClientDefaultExport","src","dest","type","options","callback","fs","readFile","err","contents","once","tsconfig","getTS","getTsconfig","config","compilerOptions","module","target","basename","path","transformSync","output","extname","destFilePath","join","replace","mkdirp","dirname","queue","Queue","defer","writeFile","bind","sourceMaps","map","await"],"mappings":";;;;+BAwCA;;;eAAwBA;;;yDAxCT;2DACE;iEACA;yEACM;oEACJ;8DACD;oEAEQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,IAAMC,eAAe;AACrB,IAAMC,eAAe;AACrB,IAAMC,WAAW,IAAIC,OAAO,AAAC,uBAAsDH,OAAhCC,cAAa,qBAAgC,OAAbD,cAAa,UAAQ;AACxG,IAAMI,WAAW,IAAID,OAAO,AAAC,GAAuBF,OAArBC,UAAS,cAAqCF,OAAzBC,cAAa,cAAuCA,OAA3BD,cAAa,gBAAuCA,OAAzBC,cAAa,cAAyB,OAAbD,cAAa,OAAK;AAEnJ,IAAMK,mBAAmB;IAAC;IAAO;IAAO;IAAQ;IAAQ;CAAO;AAC/D,IAAMC,mBAAmB;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ACP,aAAI,CAACQ,OAAO,CAACJ,eAAe;oBACjC,IAAMK,QAAQ,IAAIC,gBAAK;oBACvBD,MAAME,KAAK,CAACxB,WAAE,CAACyB,SAAS,CAACC,IAAI,CAAC,MAAMT,cAAcF,OAAOxC,IAAI,EAAE;oBAC/D,CAACuB,QAAQ6B,UAAU,IAAIL,MAAME,KAAK,CAACxB,WAAE,CAACyB,SAAS,CAACC,IAAI,CAAC,MAAM,AAAC,GAAe,OAAbT,cAAa,SAAOF,OAAOa,GAAG,EAAE;oBAC9FN,MAAMO,KAAK,CAAC;+BAAO3B,MAAMH,SAASG,OAAOH,SAAS,MAAMkB;;gBAC1D;YACF;QACF,EAAE,OAAOf,KAAK;YACZH,SAASG;QACX;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\
|
|
1
|
+
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\n// @ts-ignore\nimport lazy from '../lib/lazy.cjs';\n// @ts-ignore\nimport loadSWC from '../lib/loadSWC.js';\nconst lazyTS = lazy('typescript');\nconst lazyTranspiler = lazy('ts-node/transpilers/swc');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult, callback) {\n loadSWC((err, swc) => {\n if (err) return callback(err);\n const ts = lazyTS();\n const transpiler = lazyTranspiler();\n\n const parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path));\n const transpile = transpiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName });\n callback(null, { code: res.outputText, map: res.sourceMapText });\n });\n}\n"],"names":["transformSyncWorker","lazyTS","lazy","lazyTranspiler","contents","fileName","tsconfig","callback","loadSWC","err","swc","ts","transpiler","parsed","parseJsonConfigFileContent","config","sys","path","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":";;;;+BASA;;;eAAwBA;;;2DATP;8DAEA;8DAEG;;;;;;AACpB,IAAMC,SAASC,IAAAA,gBAAI,EAAC;AACpB,IAAMC,iBAAiBD,IAAAA,gBAAI,EAAC;AAGb,SAASF,oBAAoBI,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB,EAAEC,QAAQ;IAChHC,IAAAA,gBAAO,EAAC,SAACC,KAAKC;QACZ,IAAID,KAAK,OAAOF,SAASE;QACzB,IAAME,KAAKV;QACX,IAAMW,aAAaT;QAEnB,IAAMU,SAASF,GAAGG,0BAA0B,CAACR,SAASS,MAAM,EAAEJ,GAAGK,GAAG,EAAEC,aAAI,CAACC,OAAO,CAACZ,SAASW,IAAI;QAChG,IAAME,YAAYP,WAAWQ,MAAM,CAAC;YAAEV,KAAKA;YAAKW,SAAS;gBAAEN,QAAQ;oBAAEO,SAAST,OAAOS,OAAO;gBAAC;YAAE;QAAE;QACjG,IAAMC,MAAMJ,UAAUA,SAAS,CAACf,UAAU;YAAEC,UAAAA;QAAS;QACrDE,SAAS,MAAM;YAAEiB,MAAMD,IAAIE,UAAU;YAAEC,KAAKH,IAAII,aAAa;QAAC;IAChE;AACF"}
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _crossspawncb = /*#__PURE__*/ _interop_require_default(require("cross-spawn-cb"));
|
|
12
12
|
var _fsiterator = /*#__PURE__*/ _interop_require_default(require("fs-iterator"));
|
|
13
|
-
var _gettsconfigcompat = /*#__PURE__*/
|
|
13
|
+
var _gettsconfigcompat = /*#__PURE__*/ _interop_require_wildcard(require("get-tsconfig-compat"));
|
|
14
14
|
var _rimraf2 = /*#__PURE__*/ _interop_require_default(require("rimraf2"));
|
|
15
15
|
var _constants = require("../constants.js");
|
|
16
16
|
var _createMatcher = /*#__PURE__*/ _interop_require_default(require("../createMatcher.js"));
|
|
@@ -27,6 +27,47 @@ function _interop_require_default(obj) {
|
|
|
27
27
|
default: obj
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
31
|
+
if (typeof WeakMap !== "function") return null;
|
|
32
|
+
var cacheBabelInterop = new WeakMap();
|
|
33
|
+
var cacheNodeInterop = new WeakMap();
|
|
34
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
35
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
36
|
+
})(nodeInterop);
|
|
37
|
+
}
|
|
38
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
39
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
43
|
+
return {
|
|
44
|
+
default: obj
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
48
|
+
if (cache && cache.has(obj)) {
|
|
49
|
+
return cache.get(obj);
|
|
50
|
+
}
|
|
51
|
+
var newObj = {
|
|
52
|
+
__proto__: null
|
|
53
|
+
};
|
|
54
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
55
|
+
for(var key in obj){
|
|
56
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
57
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
58
|
+
if (desc && (desc.get || desc.set)) {
|
|
59
|
+
Object.defineProperty(newObj, key, desc);
|
|
60
|
+
} else {
|
|
61
|
+
newObj[key] = obj[key];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
newObj.default = obj;
|
|
66
|
+
if (cache) {
|
|
67
|
+
cache.set(obj, newObj);
|
|
68
|
+
}
|
|
69
|
+
return newObj;
|
|
70
|
+
}
|
|
30
71
|
function _iterable_to_array(iter) {
|
|
31
72
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
32
73
|
}
|
|
@@ -45,7 +86,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
45
86
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
87
|
}
|
|
47
88
|
function transformTypesWorker(src, dest, options, callback) {
|
|
48
|
-
var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.
|
|
89
|
+
var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.getTsconfig(src);
|
|
49
90
|
var matcher = (0, _createMatcher.default)(tsconfig);
|
|
50
91
|
var tsArgs = [];
|
|
51
92
|
for(var key in tsconfig.config.compilerOptions){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformTypes.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n const tsArgs = [];\n for (const key in tsconfig.config.compilerOptions) {\n const value = tsconfig.config.compilerOptions[key];\n tsArgs.push(`--${key}`);\n tsArgs.push(Array.isArray(value) ? value.join(',') : value);\n }\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n if (entries.length === 0) return callback();\n\n const files = entries.map((entry) => entry.fullPath);\n const args = ['tsc', ...files, '--declaration', '--emitDeclarationOnly', '--outDir', dest, ...tsArgs];\n spawn(args[0], args.slice(1), { stdio: 'inherit' }, callback);\n }\n );\n });\n}\n"],"names":["transformTypesWorker","src","dest","options","callback","tsconfig","getTS","getTsconfig","matcher","createMatcher","tsArgs","key","config","compilerOptions","value","push","Array","isArray","join","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","fullPath","typeFileRegEx","test","basename","SKIPS","indexOf","err","length","files","map","args","spawn","slice","stdio"],"mappings":";;;;+BAQA;;;eAAwBA;;;mEARN;iEACG;
|
|
1
|
+
{"version":3,"sources":["transformTypes.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport Iterator from 'fs-iterator';\nimport * as getTS from 'get-tsconfig-compat';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n const tsArgs = [];\n for (const key in tsconfig.config.compilerOptions) {\n const value = tsconfig.config.compilerOptions[key];\n tsArgs.push(`--${key}`);\n tsArgs.push(Array.isArray(value) ? value.join(',') : value);\n }\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n if (entries.length === 0) return callback();\n\n const files = entries.map((entry) => entry.fullPath);\n const args = ['tsc', ...files, '--declaration', '--emitDeclarationOnly', '--outDir', dest, ...tsArgs];\n spawn(args[0], args.slice(1), { stdio: 'inherit' }, callback);\n }\n );\n });\n}\n"],"names":["transformTypesWorker","src","dest","options","callback","tsconfig","getTS","getTsconfig","matcher","createMatcher","tsArgs","key","config","compilerOptions","value","push","Array","isArray","join","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","fullPath","typeFileRegEx","test","basename","SKIPS","indexOf","err","length","files","map","args","spawn","slice","stdio"],"mappings":";;;;+BAQA;;;eAAwBA;;;mEARN;iEACG;yEACE;8DACH;yBAEiB;oEACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEX,SAASA,qBAAqBC,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,IAAMC,WAAWF,QAAQE,QAAQ,GAAGF,QAAQE,QAAQ,GAAGC,mBAAMC,WAAW,CAACN;IACzE,IAAMO,UAAUC,IAAAA,sBAAa,EAACJ;IAE9B,IAAMK,SAAS,EAAE;IACjB,IAAK,IAAMC,OAAON,SAASO,MAAM,CAACC,eAAe,CAAE;QACjD,IAAMC,QAAQT,SAASO,MAAM,CAACC,eAAe,CAACF,IAAI;QAClDD,OAAOK,IAAI,CAAC,AAAC,KAAQ,OAAJJ;QACjBD,OAAOK,IAAI,CAACC,MAAMC,OAAO,CAACH,SAASA,MAAMI,IAAI,CAAC,OAAOJ;IACvD;IAEAK,IAAAA,gBAAO,EAACjB,MAAM;QAAEkB,aAAa;IAAK,GAAG;QACnC,IAAMC,UAAU,EAAE;QAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAACtB;QAC9BqB,SAASE,OAAO,CACd,SAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAI,CAACnB,QAAQiB,MAAMG,QAAQ,GAAG;YAC9B,IAAIC,wBAAa,CAACC,IAAI,CAACL,MAAMM,QAAQ,GAAG;YACxC,IAAIC,gBAAK,CAACC,OAAO,CAACR,MAAMM,QAAQ,KAAK,GAAG;YACxCV,QAAQN,IAAI,CAACU;QACf,GACA,SAACS;YACC,IAAIA,KAAK,OAAO9B,SAAS8B;YACzB,IAAIb,QAAQc,MAAM,KAAK,GAAG,OAAO/B;YAEjC,IAAMgC,QAAQf,QAAQgB,GAAG,CAAC,SAACZ;uBAAUA,MAAMG,QAAQ;;YACnD,IAAMU,OAAO;gBAAC;aAAuF,CAAxF,OAAQ,qBAAGF,QAAX;gBAAkB;gBAAiB;gBAAyB;gBAAYlC;aAAgB,EAAV,qBAAGQ;YAC9F6B,IAAAA,qBAAK,EAACD,IAAI,CAAC,EAAE,EAAEA,KAAKE,KAAK,CAAC,IAAI;gBAAEC,OAAO;YAAU,GAAGrC;QACtD;IAEJ;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import Iterator from 'fs-iterator';
|
|
3
|
-
import getTS from 'get-tsconfig-compat';
|
|
3
|
+
import * as getTS from 'get-tsconfig-compat';
|
|
4
4
|
import Queue from 'queue-cb';
|
|
5
5
|
import rimraf2 from 'rimraf2';
|
|
6
6
|
import { SKIPS, typeFileRegEx } from '../constants.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\nimport transformFile from './transformFile.js';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n\n options = { ...options, tsconfig };\n const queue = new Queue();\n entries.forEach((entry) => queue.defer(transformFile.bind(null, entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options)));\n queue.await(callback);\n }\n );\n });\n}\n"],"names":["path","Iterator","getTS","Queue","rimraf2","SKIPS","typeFileRegEx","createMatcher","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","getTsconfig","matcher","disableGlob","entries","iterator","forEach","entry","stats","isFile","fullPath","test","basename","indexOf","push","err","queue","defer","bind","dirname","join","await"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,cAAc,cAAc;AACnC,
|
|
1
|
+
{"version":3,"sources":["transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport * as getTS from 'get-tsconfig-compat';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\nimport transformFile from './transformFile.js';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n\n options = { ...options, tsconfig };\n const queue = new Queue();\n entries.forEach((entry) => queue.defer(transformFile.bind(null, entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options)));\n queue.await(callback);\n }\n );\n });\n}\n"],"names":["path","Iterator","getTS","Queue","rimraf2","SKIPS","typeFileRegEx","createMatcher","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","getTsconfig","matcher","disableGlob","entries","iterator","forEach","entry","stats","isFile","fullPath","test","basename","indexOf","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 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import once from 'call-once-fn';
|
|
4
|
-
import getTS from 'get-tsconfig-compat';
|
|
4
|
+
import * as getTS from 'get-tsconfig-compat';
|
|
5
5
|
import mkdirp from 'mkdirp-classic';
|
|
6
6
|
import Queue from 'queue-cb';
|
|
7
7
|
import transformSync from './transformSync.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport once from 'call-once-fn';\nimport getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\n\nimport transformSync from './transformSync.js';\n\nconst matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nconst matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nconst regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`, 'g');\nconst regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\\\s*)?${matchingDeps};?|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`, 'g');\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nexport default function transformFileWorker(src, dest, type, options, callback) {\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.tsconfig = { ...(tsconfig.config || {}) };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'CommonJS';\n tsconfig.config.compilerOptions.target = 'ES5';\n }\n\n const basename = path.basename(src);\n transformSync(contents, basename, tsconfig, (err, output) => {\n if (err) return callback(err);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n"],"names":["fs","path","once","getTS","mkdirp","Queue","transformSync","matchingDeps","matchingName","regexCJS","RegExp","regexESM","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","matches","match","exec","dependency","ext","find","x","slice","length","push","reverse","index","start","indexOf","substring","interopClientDefaultExport","transformFileWorker","src","dest","type","options","callback","readFile","err","contents","tsconfig","getTsconfig","config","compilerOptions","module","target","basename","output","extname","destFilePath","join","replace","dirname","queue","defer","writeFile","bind","sourceMaps","map","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,UAAU,eAAe;AAChC,
|
|
1
|
+
{"version":3,"sources":["transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport once from 'call-once-fn';\nimport * as getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\n\nimport transformSync from './transformSync.js';\n\nconst matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nconst matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nconst regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`, 'g');\nconst regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\\\s*)?${matchingDeps};?|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`, 'g');\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nexport default function transformFileWorker(src, dest, type, options, callback) {\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.tsconfig = { ...(tsconfig.config || {}) };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'CommonJS';\n tsconfig.config.compilerOptions.target = 'ES5';\n }\n\n const basename = path.basename(src);\n transformSync(contents, basename, tsconfig, (err, output) => {\n if (err) return callback(err);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n"],"names":["fs","path","once","getTS","mkdirp","Queue","transformSync","matchingDeps","matchingName","regexCJS","RegExp","regexESM","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","matches","match","exec","dependency","ext","find","x","slice","length","push","reverse","index","start","indexOf","substring","interopClientDefaultExport","transformFileWorker","src","dest","type","options","callback","readFile","err","contents","tsconfig","getTsconfig","config","compilerOptions","module","target","basename","output","extname","destFilePath","join","replace","dirname","queue","defer","writeFile","bind","sourceMaps","map","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,UAAU,eAAe;AAChC,YAAYC,WAAW,sBAAsB;AAC7C,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,WAAW,WAAW;AAE7B,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,eAAe;AACrB,MAAMC,eAAe;AACrB,MAAMC,WAAW,IAAIC,OAAO,CAAC,oBAAoB,EAAEF,aAAa,iBAAiB,EAAED,aAAa,KAAK,CAAC,EAAE;AACxG,MAAMI,WAAW,IAAID,OAAO,GAAGD,SAAS,UAAU,EAAED,aAAa,UAAU,EAAED,aAAa,YAAY,EAAEC,aAAa,UAAU,EAAED,aAAa,EAAE,CAAC,EAAE;AAEnJ,MAAMK,mBAAmB;IAAC;IAAO;IAAO;IAAQ;IAAQ;CAAO;AAC/D,MAAMC,mBAAmB;IAAC;CAAO;AACjC,MAAMC,mBAAmB;IAAC;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;CAAO;AAExE,SAASC,iBAAiBC,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAEC,SAAS;IAC1D,IAAIC,UAAU,EAAE;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AIJ,MAAMC,KAAK,CAAC3D,GAAG4D,SAAS,CAACC,IAAI,CAAC,MAAM,GAAGP,aAAa,IAAI,CAAC,EAAEF,OAAOW,GAAG,EAAE;oBAC9FL,MAAMM,KAAK,CAAC,IAAOrB,MAAMF,SAASE,OAAOF,SAAS,MAAMa;gBAC1D;YACF;QACF,EAAE,OAAOX,KAAK;YACZF,SAASE;QACX;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\
|
|
1
|
+
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\n// @ts-ignore\nimport lazy from '../lib/lazy.cjs';\n// @ts-ignore\nimport loadSWC from '../lib/loadSWC.js';\nconst lazyTS = lazy('typescript');\nconst lazyTranspiler = lazy('ts-node/transpilers/swc');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult, callback) {\n loadSWC((err, swc) => {\n if (err) return callback(err);\n const ts = lazyTS();\n const transpiler = lazyTranspiler();\n\n const parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path));\n const transpile = transpiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName });\n callback(null, { code: res.outputText, map: res.sourceMapText });\n });\n}\n"],"names":["path","lazy","loadSWC","lazyTS","lazyTranspiler","transformSyncWorker","contents","fileName","tsconfig","callback","err","swc","ts","transpiler","parsed","parseJsonConfigFileContent","config","sys","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,aAAa;AACb,OAAOC,UAAU,kBAAkB;AACnC,aAAa;AACb,OAAOC,aAAa,oBAAoB;AACxC,MAAMC,SAASF,KAAK;AACpB,MAAMG,iBAAiBH,KAAK;AAG5B,eAAe,SAASI,oBAAoBC,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB,EAAEC,QAAQ;IAChHP,QAAQ,CAACQ,KAAKC;QACZ,IAAID,KAAK,OAAOD,SAASC;QACzB,MAAME,KAAKT;QACX,MAAMU,aAAaT;QAEnB,MAAMU,SAASF,GAAGG,0BAA0B,CAACP,SAASQ,MAAM,EAAEJ,GAAGK,GAAG,EAAEjB,KAAKkB,OAAO,CAACV,SAASR,IAAI;QAChG,MAAMmB,YAAYN,WAAWO,MAAM,CAAC;YAAET,KAAKA;YAAKU,SAAS;gBAAEL,QAAQ;oBAAEM,SAASR,OAAOQ,OAAO;gBAAC;YAAE;QAAE;QACjG,MAAMC,MAAMJ,UAAUA,SAAS,CAACb,UAAU;YAAEC;QAAS;QACrDE,SAAS,MAAM;YAAEe,MAAMD,IAAIE,UAAU;YAAEC,KAAKH,IAAII,aAAa;QAAC;IAChE;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import spawn from 'cross-spawn-cb';
|
|
2
2
|
import Iterator from 'fs-iterator';
|
|
3
|
-
import getTS from 'get-tsconfig-compat';
|
|
3
|
+
import * as getTS from 'get-tsconfig-compat';
|
|
4
4
|
import rimraf2 from 'rimraf2';
|
|
5
5
|
import { SKIPS, typeFileRegEx } from '../constants.mjs';
|
|
6
6
|
import createMatcher from '../createMatcher.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformTypes.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n const tsArgs = [];\n for (const key in tsconfig.config.compilerOptions) {\n const value = tsconfig.config.compilerOptions[key];\n tsArgs.push(`--${key}`);\n tsArgs.push(Array.isArray(value) ? value.join(',') : value);\n }\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n if (entries.length === 0) return callback();\n\n const files = entries.map((entry) => entry.fullPath);\n const args = ['tsc', ...files, '--declaration', '--emitDeclarationOnly', '--outDir', dest, ...tsArgs];\n spawn(args[0], args.slice(1), { stdio: 'inherit' }, callback);\n }\n );\n });\n}\n"],"names":["spawn","Iterator","getTS","rimraf2","SKIPS","typeFileRegEx","createMatcher","transformTypesWorker","src","dest","options","callback","tsconfig","getTsconfig","matcher","tsArgs","key","config","compilerOptions","value","push","Array","isArray","join","disableGlob","entries","iterator","forEach","entry","stats","isFile","fullPath","test","basename","indexOf","err","length","files","map","args","slice","stdio"],"mappings":"AAAA,OAAOA,WAAW,iBAAiB;AACnC,OAAOC,cAAc,cAAc;AACnC,
|
|
1
|
+
{"version":3,"sources":["transformTypes.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport Iterator from 'fs-iterator';\nimport * as getTS from 'get-tsconfig-compat';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants.js';\nimport createMatcher from '../createMatcher.js';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n const tsArgs = [];\n for (const key in tsconfig.config.compilerOptions) {\n const value = tsconfig.config.compilerOptions[key];\n tsArgs.push(`--${key}`);\n tsArgs.push(Array.isArray(value) ? value.join(',') : value);\n }\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n if (entries.length === 0) return callback();\n\n const files = entries.map((entry) => entry.fullPath);\n const args = ['tsc', ...files, '--declaration', '--emitDeclarationOnly', '--outDir', dest, ...tsArgs];\n spawn(args[0], args.slice(1), { stdio: 'inherit' }, callback);\n }\n );\n });\n}\n"],"names":["spawn","Iterator","getTS","rimraf2","SKIPS","typeFileRegEx","createMatcher","transformTypesWorker","src","dest","options","callback","tsconfig","getTsconfig","matcher","tsArgs","key","config","compilerOptions","value","push","Array","isArray","join","disableGlob","entries","iterator","forEach","entry","stats","isFile","fullPath","test","basename","indexOf","err","length","files","map","args","slice","stdio"],"mappings":"AAAA,OAAOA,WAAW,iBAAiB;AACnC,OAAOC,cAAc,cAAc;AACnC,YAAYC,WAAW,sBAAsB;AAC7C,OAAOC,aAAa,UAAU;AAE9B,SAASC,KAAK,EAAEC,aAAa,QAAQ,kBAAkB;AACvD,OAAOC,mBAAmB,sBAAsB;AAEhD,eAAe,SAASC,qBAAqBC,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,MAAMC,WAAWF,QAAQE,QAAQ,GAAGF,QAAQE,QAAQ,GAAGV,MAAMW,WAAW,CAACL;IACzE,MAAMM,UAAUR,cAAcM;IAE9B,MAAMG,SAAS,EAAE;IACjB,IAAK,MAAMC,OAAOJ,SAASK,MAAM,CAACC,eAAe,CAAE;QACjD,MAAMC,QAAQP,SAASK,MAAM,CAACC,eAAe,CAACF,IAAI;QAClDD,OAAOK,IAAI,CAAC,CAAC,EAAE,EAAEJ,KAAK;QACtBD,OAAOK,IAAI,CAACC,MAAMC,OAAO,CAACH,SAASA,MAAMI,IAAI,CAAC,OAAOJ;IACvD;IAEAhB,QAAQM,MAAM;QAAEe,aAAa;IAAK,GAAG;QACnC,MAAMC,UAAU,EAAE;QAClB,MAAMC,WAAW,IAAIzB,SAASO;QAC9BkB,SAASC,OAAO,CACd,CAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAI,CAAChB,QAAQc,MAAMG,QAAQ,GAAG;YAC9B,IAAI1B,cAAc2B,IAAI,CAACJ,MAAMK,QAAQ,GAAG;YACxC,IAAI7B,MAAM8B,OAAO,CAACN,MAAMK,QAAQ,KAAK,GAAG;YACxCR,QAAQL,IAAI,CAACQ;QACf,GACA,CAACO;YACC,IAAIA,KAAK,OAAOxB,SAASwB;YACzB,IAAIV,QAAQW,MAAM,KAAK,GAAG,OAAOzB;YAEjC,MAAM0B,QAAQZ,QAAQa,GAAG,CAAC,CAACV,QAAUA,MAAMG,QAAQ;YACnD,MAAMQ,OAAO;gBAAC;mBAAUF;gBAAO;gBAAiB;gBAAyB;gBAAY5B;mBAASM;aAAO;YACrGf,MAAMuC,IAAI,CAAC,EAAE,EAAEA,KAAKC,KAAK,CAAC,IAAI;gBAAEC,OAAO;YAAU,GAAG9B;QACtD;IAEJ;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-swc-transform",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@swc/core": "*",
|
|
52
52
|
"call-once-fn": "^1.0.1",
|
|
53
|
-
"cross-spawn-cb": "^1.
|
|
53
|
+
"cross-spawn-cb": "^1.3.0",
|
|
54
54
|
"exit": "^0.1.2",
|
|
55
55
|
"fs-iterator": "^5.1.1",
|
|
56
|
-
"get-tsconfig-compat": "^
|
|
56
|
+
"get-tsconfig-compat": "^2.0.1",
|
|
57
57
|
"install-module-linked": "^0.1.0",
|
|
58
58
|
"is-absolute": "^1.0.0",
|
|
59
59
|
"lazy-cache": "^2.0.2",
|