ts-swc-transform 2.8.0 → 2.8.2

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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * CJS resolver
3
+ *
4
+ * Uses the `resolve` npm package for CommonJS-style module resolution.
5
+ * Handles main field, index.js, etc.
6
+ *
7
+ * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.
8
+ */
9
+ /**
10
+ * Resolve a CJS specifier to an absolute file path
11
+ *
12
+ * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')
13
+ * @param basedir - The directory to resolve from
14
+ * @returns The resolved absolute file path
15
+ * @throws Error if module cannot be found
16
+ */
17
+ export default function resolveCJS(specifier: string, basedir: string): string;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * CJS resolver
3
+ *
4
+ * Uses the `resolve` npm package for CommonJS-style module resolution.
5
+ * Handles main field, index.js, etc.
6
+ *
7
+ * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.
8
+ */
9
+ /**
10
+ * Resolve a CJS specifier to an absolute file path
11
+ *
12
+ * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')
13
+ * @param basedir - The directory to resolve from
14
+ * @returns The resolved absolute file path
15
+ * @throws Error if module cannot be found
16
+ */
17
+ export default function resolveCJS(specifier: string, basedir: string): string;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * CJS resolver
3
+ *
4
+ * Uses the `resolve` npm package for CommonJS-style module resolution.
5
+ * Handles main field, index.js, etc.
6
+ *
7
+ * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.
8
+ */ "use strict";
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ Object.defineProperty(exports, /**
13
+ * Resolve a CJS specifier to an absolute file path
14
+ *
15
+ * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')
16
+ * @param basedir - The directory to resolve from
17
+ * @returns The resolved absolute file path
18
+ * @throws Error if module cannot be found
19
+ */ "default", {
20
+ enumerable: true,
21
+ get: function() {
22
+ return resolveCJS;
23
+ }
24
+ });
25
+ var _resolve = /*#__PURE__*/ _interop_require_wildcard(require("resolve"));
26
+ function _getRequireWildcardCache(nodeInterop) {
27
+ if (typeof WeakMap !== "function") return null;
28
+ var cacheBabelInterop = new WeakMap();
29
+ var cacheNodeInterop = new WeakMap();
30
+ return (_getRequireWildcardCache = function(nodeInterop) {
31
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
32
+ })(nodeInterop);
33
+ }
34
+ function _interop_require_wildcard(obj, nodeInterop) {
35
+ if (!nodeInterop && obj && obj.__esModule) {
36
+ return obj;
37
+ }
38
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
39
+ return {
40
+ default: obj
41
+ };
42
+ }
43
+ var cache = _getRequireWildcardCache(nodeInterop);
44
+ if (cache && cache.has(obj)) {
45
+ return cache.get(obj);
46
+ }
47
+ var newObj = {
48
+ __proto__: null
49
+ };
50
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
51
+ for(var key in obj){
52
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
53
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
54
+ if (desc && (desc.get || desc.set)) {
55
+ Object.defineProperty(newObj, key, desc);
56
+ } else {
57
+ newObj[key] = obj[key];
58
+ }
59
+ }
60
+ }
61
+ newObj.default = obj;
62
+ if (cache) {
63
+ cache.set(obj, newObj);
64
+ }
65
+ return newObj;
66
+ }
67
+ var _resolve_default;
68
+ var resolveSync = ((_resolve_default = _resolve.default) !== null && _resolve_default !== void 0 ? _resolve_default : _resolve).sync;
69
+ function resolveCJS(specifier, basedir) {
70
+ return resolveSync(specifier, {
71
+ basedir: basedir,
72
+ extensions: [
73
+ '.js',
74
+ '.json',
75
+ '.node',
76
+ '.mjs'
77
+ ]
78
+ });
79
+ }
80
+ /* 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; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/resolveCJS.ts"],"sourcesContent":["/**\n * CJS resolver\n *\n * Uses the `resolve` npm package for CommonJS-style module resolution.\n * Handles main field, index.js, etc.\n *\n * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.\n */\n\nimport * as resolve from 'resolve';\n\nconst resolveSync = (resolve.default ?? resolve).sync;\n\n/**\n * Resolve a CJS specifier to an absolute file path\n *\n * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')\n * @param basedir - The directory to resolve from\n * @returns The resolved absolute file path\n * @throws Error if module cannot be found\n */\nexport default function resolveCJS(specifier: string, basedir: string): string {\n return resolveSync(specifier, {\n basedir,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n}\n"],"names":["resolveCJS","resolve","resolveSync","default","sync","specifier","basedir","extensions"],"mappings":"AAAA;;;;;;;CAOC;;;;+BAMD;;;;;;;CAOC,GACD;;;eAAwBA;;;+DAZC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEJC;AAArB,IAAMC,cAAc,EAACD,mBAAAA,SAAQE,OAAO,cAAfF,8BAAAA,mBAAmBA,UAASG,IAAI;AAUtC,SAASJ,WAAWK,SAAiB,EAAEC,OAAe;IACnE,OAAOJ,YAAYG,WAAW;QAC5BC,SAAAA;QACAC,YAAY;YAAC;YAAO;YAAS;YAAS;SAAO;IAC/C;AACF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Unified ESM resolver
3
+ *
4
+ * Handles both:
5
+ * - Package exports: import x from 'lodash' → uses exports field
6
+ * - Subpath imports: import x from '#internal' → uses imports field
7
+ *
8
+ * Uses resolve.exports.resolve() which automatically detects the specifier type.
9
+ * Only loaded on Node >= 12.2 where module.createRequire exists.
10
+ */
11
+ /**
12
+ * Resolve an ESM specifier to an absolute file path
13
+ *
14
+ * @param specifier - The import specifier (e.g., 'lodash', 'lodash/get', '#internal')
15
+ * @param parentPath - The file path of the importing module
16
+ * @param conditions - Export conditions (defaults to ['node', 'import'])
17
+ * @returns The resolved absolute file path, or null if not resolvable
18
+ */
19
+ export default function resolveESM(specifier: string, parentPath: string, conditions?: string[]): string | null;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Unified ESM resolver
3
+ *
4
+ * Handles both:
5
+ * - Package exports: import x from 'lodash' → uses exports field
6
+ * - Subpath imports: import x from '#internal' → uses imports field
7
+ *
8
+ * Uses resolve.exports.resolve() which automatically detects the specifier type.
9
+ * Only loaded on Node >= 12.2 where module.createRequire exists.
10
+ */
11
+ /**
12
+ * Resolve an ESM specifier to an absolute file path
13
+ *
14
+ * @param specifier - The import specifier (e.g., 'lodash', 'lodash/get', '#internal')
15
+ * @param parentPath - The file path of the importing module
16
+ * @param conditions - Export conditions (defaults to ['node', 'import'])
17
+ * @returns The resolved absolute file path, or null if not resolvable
18
+ */
19
+ export default function resolveESM(specifier: string, parentPath: string, conditions?: string[]): string | null;
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Unified ESM resolver
3
+ *
4
+ * Handles both:
5
+ * - Package exports: import x from 'lodash' → uses exports field
6
+ * - Subpath imports: import x from '#internal' → uses imports field
7
+ *
8
+ * Uses resolve.exports.resolve() which automatically detects the specifier type.
9
+ * Only loaded on Node >= 12.2 where module.createRequire exists.
10
+ */ "use strict";
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ Object.defineProperty(exports, /**
15
+ * Resolve an ESM specifier to an absolute file path
16
+ *
17
+ * @param specifier - The import specifier (e.g., 'lodash', 'lodash/get', '#internal')
18
+ * @param parentPath - The file path of the importing module
19
+ * @param conditions - Export conditions (defaults to ['node', 'import'])
20
+ * @returns The resolved absolute file path, or null if not resolvable
21
+ */ "default", {
22
+ enumerable: true,
23
+ get: function() {
24
+ return resolveESM;
25
+ }
26
+ });
27
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
28
+ var _module = /*#__PURE__*/ _interop_require_default(require("module"));
29
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ var _resolveExports = null;
36
+ function getResolveExports() {
37
+ if (_resolveExports === null) {
38
+ try {
39
+ var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
40
+ _resolveExports = _require('resolve.exports');
41
+ } catch (_) {
42
+ _resolveExports = null;
43
+ }
44
+ }
45
+ return _resolveExports;
46
+ }
47
+ /**
48
+ * Parse a specifier into package name and subpath
49
+ * "lodash" → { pkgName: "lodash", subpath: "." }
50
+ * "lodash/get" → { pkgName: "lodash", subpath: "./get" }
51
+ * "@scope/pkg" → { pkgName: "@scope/pkg", subpath: "." }
52
+ * "@scope/pkg/foo" → { pkgName: "@scope/pkg", subpath: "./foo" }
53
+ */ function parseSpecifier(specifier) {
54
+ var parts = specifier.split('/');
55
+ var pkgName = specifier[0] === '@' ? parts.slice(0, 2).join('/') : parts[0];
56
+ var remainder = specifier.slice(pkgName.length);
57
+ var subpath = remainder ? ".".concat(remainder) : '.';
58
+ return {
59
+ pkgName: pkgName,
60
+ subpath: subpath
61
+ };
62
+ }
63
+ /**
64
+ * Find package.json in node_modules for external packages
65
+ */ function findPackageInNodeModules(pkgName, basedir) {
66
+ var dir = basedir;
67
+ var root = _path.default.parse(dir).root;
68
+ while(dir !== root){
69
+ var pkgDir = _path.default.join(dir, 'node_modules', pkgName);
70
+ var pkgJsonPath = _path.default.join(pkgDir, 'package.json');
71
+ try {
72
+ if (_fs.default.existsSync(pkgJsonPath)) {
73
+ var content = _fs.default.readFileSync(pkgJsonPath, 'utf8');
74
+ return {
75
+ dir: pkgDir,
76
+ json: JSON.parse(content)
77
+ };
78
+ }
79
+ } catch (_) {
80
+ // Ignore filesystem errors
81
+ }
82
+ var parent = _path.default.dirname(dir);
83
+ if (parent === dir) break;
84
+ dir = parent;
85
+ }
86
+ return null;
87
+ }
88
+ /**
89
+ * Find the containing package.json by walking up from a file path
90
+ * Used for # subpath imports which are scoped to the containing package
91
+ */ function findContainingPackage(filePath) {
92
+ var dir = _path.default.dirname(filePath);
93
+ var root = _path.default.parse(dir).root;
94
+ while(dir !== root){
95
+ var pkgJsonPath = _path.default.join(dir, 'package.json');
96
+ try {
97
+ if (_fs.default.existsSync(pkgJsonPath)) {
98
+ var content = _fs.default.readFileSync(pkgJsonPath, 'utf8');
99
+ return {
100
+ dir: dir,
101
+ json: JSON.parse(content)
102
+ };
103
+ }
104
+ } catch (_) {
105
+ // Ignore filesystem errors
106
+ }
107
+ var parent = _path.default.dirname(dir);
108
+ if (parent === dir) break;
109
+ dir = parent;
110
+ }
111
+ return null;
112
+ }
113
+ function resolveESM(specifier, parentPath) {
114
+ var conditions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [
115
+ 'node',
116
+ 'import'
117
+ ];
118
+ var resolveExportsMod = getResolveExports();
119
+ if (!resolveExportsMod) {
120
+ return null;
121
+ }
122
+ var resolveFn = resolveExportsMod.resolve, legacy = resolveExportsMod.legacy;
123
+ // Determine how to find the package.json based on specifier type
124
+ var pkg;
125
+ var subpath;
126
+ if (specifier.startsWith('#')) {
127
+ // Subpath import - find containing package
128
+ pkg = findContainingPackage(parentPath);
129
+ subpath = specifier; // resolve.exports expects the full #specifier
130
+ } else {
131
+ // External package - find in node_modules
132
+ var _parseSpecifier = parseSpecifier(specifier), pkgName = _parseSpecifier.pkgName, parsedSubpath = _parseSpecifier.subpath;
133
+ pkg = findPackageInNodeModules(pkgName, parentPath);
134
+ subpath = parsedSubpath;
135
+ }
136
+ if (!pkg) {
137
+ return null;
138
+ }
139
+ // Use resolve.exports.resolve() which handles both exports and imports
140
+ try {
141
+ var resolved = resolveFn(pkg.json, subpath, {
142
+ conditions: conditions
143
+ });
144
+ if (resolved === null || resolved === void 0 ? void 0 : resolved[0]) {
145
+ return _path.default.join(pkg.dir, resolved[0]);
146
+ }
147
+ } catch (_) {
148
+ // Resolution failed, try legacy
149
+ }
150
+ // Try legacy main/module fields for non-# imports
151
+ if (!specifier.startsWith('#')) {
152
+ try {
153
+ var legacyMain = legacy(pkg.json);
154
+ if (legacyMain) {
155
+ var mainPath;
156
+ if (typeof legacyMain === 'string') {
157
+ mainPath = legacyMain;
158
+ } else if (Array.isArray(legacyMain)) {
159
+ mainPath = legacyMain[0];
160
+ }
161
+ if (mainPath) {
162
+ return _path.default.join(pkg.dir, mainPath);
163
+ }
164
+ }
165
+ } catch (_) {
166
+ // Legacy parsing failed
167
+ }
168
+ // Last resort: try index.js
169
+ var indexPath = _path.default.join(pkg.dir, 'index.js');
170
+ try {
171
+ if (_fs.default.existsSync(indexPath)) {
172
+ return indexPath;
173
+ }
174
+ } catch (_) {
175
+ // Ignore
176
+ }
177
+ }
178
+ return null;
179
+ }
180
+ /* 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; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/resolveESM.ts"],"sourcesContent":["/**\n * Unified ESM resolver\n *\n * Handles both:\n * - Package exports: import x from 'lodash' → uses exports field\n * - Subpath imports: import x from '#internal' → uses imports field\n *\n * Uses resolve.exports.resolve() which automatically detects the specifier type.\n * Only loaded on Node >= 12.2 where module.createRequire exists.\n */\n\nimport fs from 'fs';\nimport Module from 'module';\nimport path from 'path';\n\n// Lazy-load resolve.exports\ntype ResolveExportsModule = typeof import('resolve.exports');\nlet _resolveExports: ResolveExportsModule | null = null;\n\nfunction getResolveExports(): ResolveExportsModule | null {\n if (_resolveExports === null) {\n try {\n const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n _resolveExports = _require('resolve.exports') as ResolveExportsModule;\n } catch (_) {\n _resolveExports = null;\n }\n }\n return _resolveExports;\n}\n\n/**\n * Parse a specifier into package name and subpath\n * \"lodash\" → { pkgName: \"lodash\", subpath: \".\" }\n * \"lodash/get\" → { pkgName: \"lodash\", subpath: \"./get\" }\n * \"@scope/pkg\" → { pkgName: \"@scope/pkg\", subpath: \".\" }\n * \"@scope/pkg/foo\" → { pkgName: \"@scope/pkg\", subpath: \"./foo\" }\n */\nfunction parseSpecifier(specifier: string): { pkgName: string; subpath: string } {\n const parts = specifier.split('/');\n const pkgName = specifier[0] === '@' ? parts.slice(0, 2).join('/') : parts[0];\n const remainder = specifier.slice(pkgName.length);\n const subpath = remainder ? `.${remainder}` : '.';\n return { pkgName, subpath };\n}\n\n/**\n * Find package.json in node_modules for external packages\n */\nfunction findPackageInNodeModules(pkgName: string, basedir: string): { dir: string; json: Record<string, unknown> } | null {\n let dir = basedir;\n const root = path.parse(dir).root;\n\n while (dir !== root) {\n const pkgDir = path.join(dir, 'node_modules', pkgName);\n const pkgJsonPath = path.join(pkgDir, 'package.json');\n try {\n if (fs.existsSync(pkgJsonPath)) {\n const content = fs.readFileSync(pkgJsonPath, 'utf8');\n return { dir: pkgDir, json: JSON.parse(content) };\n }\n } catch (_) {\n // Ignore filesystem errors\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n return null;\n}\n\n/**\n * Find the containing package.json by walking up from a file path\n * Used for # subpath imports which are scoped to the containing package\n */\nfunction findContainingPackage(filePath: string): { dir: string; json: Record<string, unknown> } | null {\n let dir = path.dirname(filePath);\n const root = path.parse(dir).root;\n\n while (dir !== root) {\n const pkgJsonPath = path.join(dir, 'package.json');\n try {\n if (fs.existsSync(pkgJsonPath)) {\n const content = fs.readFileSync(pkgJsonPath, 'utf8');\n return { dir, json: JSON.parse(content) };\n }\n } catch (_) {\n // Ignore filesystem errors\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n return null;\n}\n\n/**\n * Resolve an ESM specifier to an absolute file path\n *\n * @param specifier - The import specifier (e.g., 'lodash', 'lodash/get', '#internal')\n * @param parentPath - The file path of the importing module\n * @param conditions - Export conditions (defaults to ['node', 'import'])\n * @returns The resolved absolute file path, or null if not resolvable\n */\nexport default function resolveESM(specifier: string, parentPath: string, conditions: string[] = ['node', 'import']): string | null {\n const resolveExportsMod = getResolveExports();\n if (!resolveExportsMod) {\n return null;\n }\n\n const { resolve: resolveFn, legacy } = resolveExportsMod;\n\n // Determine how to find the package.json based on specifier type\n let pkg: { dir: string; json: Record<string, unknown> } | null;\n let subpath: string;\n\n if (specifier.startsWith('#')) {\n // Subpath import - find containing package\n pkg = findContainingPackage(parentPath);\n subpath = specifier; // resolve.exports expects the full #specifier\n } else {\n // External package - find in node_modules\n const { pkgName, subpath: parsedSubpath } = parseSpecifier(specifier);\n pkg = findPackageInNodeModules(pkgName, parentPath);\n subpath = parsedSubpath;\n }\n\n if (!pkg) {\n return null;\n }\n\n // Use resolve.exports.resolve() which handles both exports and imports\n try {\n const resolved = resolveFn(pkg.json, subpath, { conditions });\n if (resolved?.[0]) {\n return path.join(pkg.dir, resolved[0]);\n }\n } catch (_) {\n // Resolution failed, try legacy\n }\n\n // Try legacy main/module fields for non-# imports\n if (!specifier.startsWith('#')) {\n try {\n const legacyMain = legacy(pkg.json);\n if (legacyMain) {\n let mainPath: string | undefined;\n if (typeof legacyMain === 'string') {\n mainPath = legacyMain;\n } else if (Array.isArray(legacyMain)) {\n mainPath = legacyMain[0];\n }\n if (mainPath) {\n return path.join(pkg.dir, mainPath);\n }\n }\n } catch (_) {\n // Legacy parsing failed\n }\n\n // Last resort: try index.js\n const indexPath = path.join(pkg.dir, 'index.js');\n try {\n if (fs.existsSync(indexPath)) {\n return indexPath;\n }\n } catch (_) {\n // Ignore\n }\n }\n\n return null;\n}\n"],"names":["resolveESM","_resolveExports","getResolveExports","_require","require","Module","createRequire","_","parseSpecifier","specifier","parts","split","pkgName","slice","join","remainder","length","subpath","findPackageInNodeModules","basedir","dir","root","path","parse","pkgDir","pkgJsonPath","fs","existsSync","content","readFileSync","json","JSON","parent","dirname","findContainingPackage","filePath","parentPath","conditions","resolveExportsMod","resolve","resolveFn","legacy","pkg","startsWith","parsedSubpath","resolved","legacyMain","mainPath","Array","isArray","indexPath"],"mappings":"AAAA;;;;;;;;;CASC;;;;+BAyFD;;;;;;;CAOC,GACD;;;eAAwBA;;;yDA/FT;6DACI;2DACF;;;;;;AAIjB,IAAIC,kBAA+C;AAEnD,SAASC;IACP,IAAID,oBAAoB,MAAM;QAC5B,IAAI;YACF,IAAME,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;YAC1FH,kBAAkBE,SAAS;QAC7B,EAAE,OAAOI,GAAG;YACVN,kBAAkB;QACpB;IACF;IACA,OAAOA;AACT;AAEA;;;;;;CAMC,GACD,SAASO,eAAeC,SAAiB;IACvC,IAAMC,QAAQD,UAAUE,KAAK,CAAC;IAC9B,IAAMC,UAAUH,SAAS,CAAC,EAAE,KAAK,MAAMC,MAAMG,KAAK,CAAC,GAAG,GAAGC,IAAI,CAAC,OAAOJ,KAAK,CAAC,EAAE;IAC7E,IAAMK,YAAYN,UAAUI,KAAK,CAACD,QAAQI,MAAM;IAChD,IAAMC,UAAUF,YAAY,AAAC,IAAa,OAAVA,aAAc;IAC9C,OAAO;QAAEH,SAAAA;QAASK,SAAAA;IAAQ;AAC5B;AAEA;;CAEC,GACD,SAASC,yBAAyBN,OAAe,EAAEO,OAAe;IAChE,IAAIC,MAAMD;IACV,IAAME,OAAOC,aAAI,CAACC,KAAK,CAACH,KAAKC,IAAI;IAEjC,MAAOD,QAAQC,KAAM;QACnB,IAAMG,SAASF,aAAI,CAACR,IAAI,CAACM,KAAK,gBAAgBR;QAC9C,IAAMa,cAAcH,aAAI,CAACR,IAAI,CAACU,QAAQ;QACtC,IAAI;YACF,IAAIE,WAAE,CAACC,UAA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require_default(require("is-absolute"));
12
12
  var _module = /*#__PURE__*/ _interop_require_default(require("module"));
13
13
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
14
- var _resolve = /*#__PURE__*/ _interop_require_wildcard(require("resolve"));
15
14
  var _url = /*#__PURE__*/ _interop_require_default(require("url"));
16
15
  var _compatts = require("./compat.js");
17
16
  var _constantsts = require("./constants.js");
18
- var _resolvewithexportsts = /*#__PURE__*/ _interop_require_default(require("./lib/resolve-with-exports.js"));
17
+ var _resolveCJSts = /*#__PURE__*/ _interop_require_default(require("./lib/resolveCJS.js"));
18
+ var _resolveESMts = /*#__PURE__*/ _interop_require_default(require("./lib/resolveESM.js"));
19
19
  var _urlFileUrlts = /*#__PURE__*/ _interop_require_wildcard(require("./lib/urlFileUrl.js"));
20
20
  function _interop_require_default(obj) {
21
21
  return obj && obj.__esModule ? obj : {
@@ -63,40 +63,45 @@ function _interop_require_wildcard(obj, nodeInterop) {
63
63
  }
64
64
  return newObj;
65
65
  }
66
- var _resolve_default;
67
- var resolveSync = ((_resolve_default = _resolve.default) !== null && _resolve_default !== void 0 ? _resolve_default : _resolve).sync;
68
66
  var useCJS = !_module.default.createRequire;
69
67
  var fileURLToPath = _url.default.fileURLToPath || _urlFileUrlts.fileURLToPath;
70
68
  function getParentPath(context) {
71
69
  if (context.parentPath) return _path.default.dirname(context.parentPath);
72
70
  return context.parentURL ? _path.default.dirname(toPath(context.parentURL)) : process.cwd();
73
71
  }
72
+ function getParentFilePath(context) {
73
+ if (context === null || context === void 0 ? void 0 : context.parentPath) return context.parentPath;
74
+ if (context === null || context === void 0 ? void 0 : context.parentURL) return fileURLToPath(context.parentURL);
75
+ return _path.default.join(process.cwd(), 'index.js');
76
+ }
74
77
  function toPath(specifier, context) {
78
+ // Handle file:// URLs
75
79
  if ((0, _compatts.stringStartsWith)(specifier, 'file:')) return fileURLToPath(specifier);
80
+ // Handle absolute paths
76
81
  if ((0, _isabsolute.default)(specifier)) return specifier;
82
+ // Handle relative paths
77
83
  if (specifier[0] === '.') {
78
84
  var parentPath = context ? getParentPath(context) : process.cwd();
79
85
  return _path.default.join(parentPath, specifier);
80
86
  }
81
- if (_constantsts.moduleRegEx.test(specifier)) {
82
- var parentPath1 = context ? getParentPath(context) : process.cwd();
83
- if (!useCJS) {
84
- try {
85
- var entryPath = (0, _resolvewithexportsts.default)(specifier, parentPath1);
86
- if (entryPath) return entryPath;
87
- } catch (_) {
88
- /* it may fail due to commonjs edge cases */ }
87
+ // Handle module specifiers (bare specifiers and # imports)
88
+ // moduleRegEx matches: bare specifiers like 'lodash', '@scope/pkg'
89
+ // specifier[0] === '#' matches: subpath imports like '#internal'
90
+ if (_constantsts.moduleRegEx.test(specifier) || specifier[0] === '#') {
91
+ var parentFilePath = getParentFilePath(context);
92
+ var parentDir = _path.default.dirname(parentFilePath);
93
+ if (useCJS) {
94
+ // CJS: use resolve package (does not support # imports)
95
+ if (specifier[0] === '#') {
96
+ throw new Error("Cannot find module '".concat(specifier, "' from '").concat(parentDir, "' (subpath imports not supported in CJS mode)"));
97
+ }
98
+ return (0, _resolveCJSts.default)(specifier, parentDir);
89
99
  }
90
- var entryPath1 = resolveSync(specifier, {
91
- basedir: parentPath1,
92
- extensions: [
93
- '.js',
94
- '.json',
95
- '.node',
96
- '.mjs'
97
- ]
98
- });
99
- if (entryPath1) return entryPath1;
100
+ // ESM: use unified resolver that handles both exports and imports
101
+ var entryPath = (0, _resolveESMts.default)(specifier, parentFilePath);
102
+ if (entryPath) return entryPath;
103
+ // If ESM resolver failed, throw meaningful error
104
+ throw new Error("Cannot find module '".concat(specifier, "' from '").concat(parentDir, "'"));
100
105
  }
101
106
  return specifier;
102
107
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport * as resolve from 'resolve';\nimport url from 'url';\n\nimport { stringStartsWith } from './compat.ts';\nimport { moduleRegEx } from './constants.ts';\nimport resolveWithExports from './lib/resolve-with-exports.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst resolveSync = (resolve.default ?? resolve).sync;\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n if (stringStartsWith(specifier, 'file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n if (!useCJS) {\n try {\n const entryPath = resolveWithExports(specifier, parentPath);\n if (entryPath) return entryPath;\n } catch (_) {\n /* it may fail due to commonjs edge cases */\n }\n }\n const entryPath = resolveSync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n if (entryPath) return entryPath;\n }\n\n return specifier;\n}\n"],"names":["toPath","resolve","resolveSync","default","sync","useCJS","module","createRequire","fileURLToPath","url","urlPolyfills","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","specifier","stringStartsWith","isAbsolute","join","moduleRegEx","test","entryPath","resolveWithExports","_","basedir","extensions"],"mappings":";;;;+BAsBA;;;eAAwBA;;;iEAtBD;6DACJ;2DACF;+DACQ;0DACT;wBAEiB;2BACL;2EACG;oEACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGTC;AAArB,IAAMC,cAAc,AAACD,CAAAA,CAAAA,mBAAAA,SAAQE,OAAO,cAAfF,8BAAAA,mBAAmBA,QAAM,EAAGG,IAAI;AAErD,IAAMC,SAAS,CAACC,eAAM,CAACC,aAAa;AACpC,IAAMC,gBAAgBC,YAAG,CAACD,aAAa,IAAIE,cAAaF,aAAa;AAErE,SAASG,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOC,aAAI,CAACC,OAAO,CAACH,QAAQC,UAAU;IAC9D,OAAOD,QAAQI,SAAS,GAAGF,aAAI,CAACC,OAAO,CAACf,OAAOY,QAAQI,SAAS,KAAKC,QAAQC,GAAG;AAClF;AAEe,SAASlB,OAAOmB,SAAiB,EAAEP,OAAiB;IACjE,IAAIQ,IAAAA,0BAAgB,EAACD,WAAW,UAAU,OAAOX,cAAcW;IAC/D,IAAIE,IAAAA,mBAAU,EAACF,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,IAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOJ,aAAI,CAACQ,IAAI,CAACT,YAAYM;IAC/B;IACA,IAAII,wBAAW,CAACC,IAAI,CAACL,YAAY;QAC/B,IAAMN,cAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,IAAI,CAACb,QAAQ;YACX,IAAI;gBACF,IAAMoB,YAAYC,IAAAA,6BAAkB,EAACP,WAAWN;gBAChD,IAAIY,WAAW,OAAOA;YACxB,EAAE,OAAOE,GAAG;YACV,0CAA0C,GAC5C;QACF;QACA,IAAMF,aAAYvB,YAAYiB,WAAW;YACvCS,SAASf;YACTgB,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;QAC/C;QACA,IAAIJ,YAAW,OAAOA;IACxB;IAEA,OAAON;AACT"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport url from 'url';\n\nimport { stringStartsWith } from './compat.ts';\nimport { moduleRegEx } from './constants.ts';\nimport resolveCJS from './lib/resolveCJS.ts';\nimport resolveESM from './lib/resolveESM.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nfunction getParentFilePath(context?: Context): string {\n if (context?.parentPath) return context.parentPath;\n if (context?.parentURL) return fileURLToPath(context.parentURL);\n return path.join(process.cwd(), 'index.js');\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n // Handle file:// URLs\n if (stringStartsWith(specifier, 'file:')) return fileURLToPath(specifier);\n\n // Handle absolute paths\n if (isAbsolute(specifier)) return specifier;\n\n // Handle relative paths\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n\n // Handle module specifiers (bare specifiers and # imports)\n // moduleRegEx matches: bare specifiers like 'lodash', '@scope/pkg'\n // specifier[0] === '#' matches: subpath imports like '#internal'\n if (moduleRegEx.test(specifier) || specifier[0] === '#') {\n const parentFilePath = getParentFilePath(context);\n const parentDir = path.dirname(parentFilePath);\n\n if (useCJS) {\n // CJS: use resolve package (does not support # imports)\n if (specifier[0] === '#') {\n throw new Error(`Cannot find module '${specifier}' from '${parentDir}' (subpath imports not supported in CJS mode)`);\n }\n return resolveCJS(specifier, parentDir);\n }\n // ESM: use unified resolver that handles both exports and imports\n const entryPath = resolveESM(specifier, parentFilePath);\n if (entryPath) return entryPath;\n\n // If ESM resolver failed, throw meaningful error\n throw new Error(`Cannot find module '${specifier}' from '${parentDir}'`);\n }\n\n return specifier;\n}\n"],"names":["toPath","useCJS","module","createRequire","fileURLToPath","url","urlPolyfills","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","getParentFilePath","join","specifier","stringStartsWith","isAbsolute","moduleRegEx","test","parentFilePath","parentDir","Error","resolveCJS","entryPath","resolveESM"],"m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AAO,CAACW;QAE/B,IAAIrB,QAAQ;YACV,wDAAwD;YACxD,IAAIgB,SAAS,CAAC,EAAE,KAAK,KAAK;gBACxB,MAAM,IAAIO,MAAM,AAAC,uBAA0CD,OAApBN,WAAU,YAAoB,OAAVM,WAAU;YACvE;YACA,OAAOE,IAAAA,qBAAU,EAACR,WAAWM;QAC/B;QACA,kEAAkE;QAClE,IAAMG,YAAYC,IAAAA,qBAAU,EAACV,WAAWK;QACxC,IAAII,WAAW,OAAOA;QAEtB,iDAAiD;QACjD,MAAM,IAAIF,MAAM,AAAC,uBAA0CD,OAApBN,WAAU,YAAoB,OAAVM,WAAU;IACvE;IAEA,OAAON;AACT"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * CJS resolver
3
+ *
4
+ * Uses the `resolve` npm package for CommonJS-style module resolution.
5
+ * Handles main field, index.js, etc.
6
+ *
7
+ * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.
8
+ */
9
+ /**
10
+ * Resolve a CJS specifier to an absolute file path
11
+ *
12
+ * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')
13
+ * @param basedir - The directory to resolve from
14
+ * @returns The resolved absolute file path
15
+ * @throws Error if module cannot be found
16
+ */
17
+ export default function resolveCJS(specifier: string, basedir: string): string;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * CJS resolver
3
+ *
4
+ * Uses the `resolve` npm package for CommonJS-style module resolution.
5
+ * Handles main field, index.js, etc.
6
+ *
7
+ * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.
8
+ */ import * as resolve from 'resolve';
9
+ var _resolve_default;
10
+ const resolveSync = ((_resolve_default = resolve.default) !== null && _resolve_default !== void 0 ? _resolve_default : resolve).sync;
11
+ /**
12
+ * Resolve a CJS specifier to an absolute file path
13
+ *
14
+ * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')
15
+ * @param basedir - The directory to resolve from
16
+ * @returns The resolved absolute file path
17
+ * @throws Error if module cannot be found
18
+ */ export default function resolveCJS(specifier, basedir) {
19
+ return resolveSync(specifier, {
20
+ basedir,
21
+ extensions: [
22
+ '.js',
23
+ '.json',
24
+ '.node',
25
+ '.mjs'
26
+ ]
27
+ });
28
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/resolveCJS.ts"],"sourcesContent":["/**\n * CJS resolver\n *\n * Uses the `resolve` npm package for CommonJS-style module resolution.\n * Handles main field, index.js, etc.\n *\n * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.\n */\n\nimport * as resolve from 'resolve';\n\nconst resolveSync = (resolve.default ?? resolve).sync;\n\n/**\n * Resolve a CJS specifier to an absolute file path\n *\n * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')\n * @param basedir - The directory to resolve from\n * @returns The resolved absolute file path\n * @throws Error if module cannot be found\n */\nexport default function resolveCJS(specifier: string, basedir: string): string {\n return resolveSync(specifier, {\n basedir,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n}\n"],"names":["resolve","resolveSync","default","sync","resolveCJS","specifier","basedir","extensions"],"mappings":"AAAA;;;;;;;CAOC,GAED,YAAYA,aAAa,UAAU;IAEdA;AAArB,MAAMC,cAAc,EAACD,mBAAAA,QAAQE,OAAO,cAAfF,8BAAAA,mBAAmBA,SAASG,IAAI;AAErD;;;;;;;CAOC,GACD,eAAe,SAASC,WAAWC,SAAiB,EAAEC,OAAe;IACnE,OAAOL,YAAYI,WAAW;QAC5BC;QACAC,YAAY;YAAC;YAAO;YAAS;YAAS;SAAO;IAC/C;AACF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Unified ESM resolver
3
+ *
4
+ * Handles both:
5
+ * - Package exports: import x from 'lodash' → uses exports field
6
+ * - Subpath imports: import x from '#internal' → uses imports field
7
+ *
8
+ * Uses resolve.exports.resolve() which automatically detects the specifier type.
9
+ * Only loaded on Node >= 12.2 where module.createRequire exists.
10
+ */
11
+ /**
12
+ * Resolve an ESM specifier to an absolute file path
13
+ *
14
+ * @param specifier - The import specifier (e.g., 'lodash', 'lodash/get', '#internal')
15
+ * @param parentPath - The file path of the importing module
16
+ * @param conditions - Export conditions (defaults to ['node', 'import'])
17
+ * @returns The resolved absolute file path, or null if not resolvable
18
+ */
19
+ export default function resolveESM(specifier: string, parentPath: string, conditions?: string[]): string | null;