@poppinss/ts-exec 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/loader.js +17 -7
- package/package.json +5 -5
package/build/src/loader.js
CHANGED
|
@@ -112,6 +112,9 @@ function transformSync(source, options) {
|
|
|
112
112
|
// src/loader.ts
|
|
113
113
|
var swcConfig;
|
|
114
114
|
var tsConfig;
|
|
115
|
+
function isTypeScriptFile(filePath) {
|
|
116
|
+
return !filePath.endsWith(".d.ts") && (filePath.endsWith(".ts") || filePath.endsWith(".tsx") || filePath.endsWith(".mts") || filePath.endsWith(".cts"));
|
|
117
|
+
}
|
|
115
118
|
function isLocalPath(specifier) {
|
|
116
119
|
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file:");
|
|
117
120
|
}
|
|
@@ -143,21 +146,28 @@ async function initialize() {
|
|
|
143
146
|
}
|
|
144
147
|
var resolve = async (specifier, context, nextResolve) => {
|
|
145
148
|
debug_default("resolving specifier %s", specifier);
|
|
149
|
+
const [pathname] = specifier.split("?");
|
|
150
|
+
if (!tsConfig?.compilerOptions?.rewriteRelativeImportExtensions && context.parentURL && isTypeScriptFile(pathname)) {
|
|
151
|
+
throw new Error(
|
|
152
|
+
`Cannot import "${specifier}" using "${extname(pathname)}" extension. Enable "compilerOptions.rewriteRelativeImportExtensions" to import TypeScript files`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
146
155
|
try {
|
|
147
156
|
return await nextResolve(specifier, context);
|
|
148
157
|
} catch (error) {
|
|
149
|
-
if (
|
|
150
|
-
let
|
|
151
|
-
const fileExtension = extname(
|
|
158
|
+
if (error.code === "ERR_MODULE_NOT_FOUND" && error.url && isLocalPath(error.url)) {
|
|
159
|
+
let [urlPathname, ...urlQs] = error.url.split("?");
|
|
160
|
+
const fileExtension = extname(urlPathname);
|
|
152
161
|
if (fileExtension === ".js") {
|
|
153
|
-
|
|
162
|
+
urlPathname = urlPathname.replace(".js", ".ts");
|
|
154
163
|
} else if (fileExtension === ".mjs") {
|
|
155
|
-
|
|
164
|
+
urlPathname = urlPathname.replace(".mjs", ".mts");
|
|
156
165
|
} else if (fileExtension === ".cjs") {
|
|
157
|
-
|
|
166
|
+
urlPathname = urlPathname.replace(".cjs", ".cts");
|
|
158
167
|
} else if (fileExtension === ".jsx") {
|
|
159
|
-
|
|
168
|
+
urlPathname = urlPathname.replace(".jsx", ".tsx");
|
|
160
169
|
}
|
|
170
|
+
const url = urlQs.length ? `${urlPathname}?${urlQs.join("?")}` : urlPathname;
|
|
161
171
|
debug_default("retrying to resolve file with specifier %s", url);
|
|
162
172
|
return nextResolve(url, context);
|
|
163
173
|
}
|
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
|
+
"version": "1.4.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@japa/runner": "^4.2.0",
|
|
41
41
|
"@japa/snapshot": "^2.0.8",
|
|
42
42
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
43
|
-
"@types/node": "^22.15.
|
|
43
|
+
"@types/node": "^22.15.30",
|
|
44
44
|
"c8": "^10.1.3",
|
|
45
|
-
"eslint": "^9.
|
|
45
|
+
"eslint": "^9.28.0",
|
|
46
46
|
"ipaddr.js": "^2.2.0",
|
|
47
|
-
"preact": "^10.26.
|
|
47
|
+
"preact": "^10.26.8",
|
|
48
48
|
"preact-render-to-string": "^6.5.13",
|
|
49
49
|
"prettier": "^3.5.3",
|
|
50
|
-
"release-it": "^19.0.
|
|
50
|
+
"release-it": "^19.0.3",
|
|
51
51
|
"tsup": "^8.5.0",
|
|
52
52
|
"typescript": "^5.8.3"
|
|
53
53
|
},
|