@poppinss/ts-exec 1.4.3 → 1.4.4

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.
Files changed (2) hide show
  1. package/build/src/loader.js +14 -10
  2. package/package.json +2 -2
@@ -164,18 +164,22 @@ var resolve = async (specifier, context, nextResolve) => {
164
164
  if (error.code === "ERR_MODULE_NOT_FOUND" && error.url && isLocalPath(error.url)) {
165
165
  let [urlPathname, ...urlQs] = error.url.split("?");
166
166
  const fileExtension = extname(urlPathname);
167
+ const testExtensions = [];
168
+ if ([".js", ".mjs", ".cjs", ".jsx"].includes(fileExtension)) {
169
+ testExtensions.push(fileExtension.replace("js", "ts"));
170
+ }
167
171
  if (fileExtension === ".js") {
168
- urlPathname = urlPathname.replace(".js", ".ts");
169
- } else if (fileExtension === ".mjs") {
170
- urlPathname = urlPathname.replace(".mjs", ".mts");
171
- } else if (fileExtension === ".cjs") {
172
- urlPathname = urlPathname.replace(".cjs", ".cts");
173
- } else if (fileExtension === ".jsx") {
174
- urlPathname = urlPathname.replace(".jsx", ".tsx");
172
+ testExtensions.push(".tsx");
173
+ }
174
+ for (const ext of testExtensions) {
175
+ const tryPath = urlPathname.slice(0, -fileExtension.length) + ext;
176
+ try {
177
+ const url = urlQs.length ? `${tryPath}?${urlQs.join("?")}` : tryPath;
178
+ debug_default("retrying to resolve file with specifier %s", url);
179
+ return await nextResolve(url, context);
180
+ } catch {
181
+ }
175
182
  }
176
- const url = urlQs.length ? `${urlPathname}?${urlQs.join("?")}` : urlPathname;
177
- debug_default("retrying to resolve file with specifier %s", url);
178
- return nextResolve(url, context);
179
183
  }
180
184
  throw error;
181
185
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@poppinss/ts-exec",
3
3
  "description": "TypeScript JIT compiler built for correctness and supports legacy/experimental decorators",
4
- "version": "1.4.3",
4
+ "version": "1.4.4",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -52,7 +52,7 @@
52
52
  "typescript": "^5.9.3"
53
53
  },
54
54
  "dependencies": {
55
- "@swc/core": "1.15.3",
55
+ "@swc/core": "~1.15.11",
56
56
  "get-tsconfig": "^4.13.0"
57
57
  },
58
58
  "homepage": "https://github.com/poppinss/ts-exec#readme",