@poppinss/ts-exec 1.1.1 → 1.1.3
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 +3 -18
- package/build/src/transform.d.ts +1 -1
- package/package.json +3 -7
package/build/src/loader.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/loader.ts
|
|
2
2
|
import { extname } from "node:path";
|
|
3
3
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
4
|
-
import { createError } from "@poppinss/exception";
|
|
5
4
|
import { resolveImports } from "resolve-pkg-maps";
|
|
6
5
|
|
|
7
6
|
// src/debug.ts
|
|
@@ -93,7 +92,7 @@ function getConfig(searchPath) {
|
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
// src/transform.ts
|
|
96
|
-
import {
|
|
95
|
+
import { transform as swcTransform } from "@swc/core";
|
|
97
96
|
function transformSync(source, options) {
|
|
98
97
|
const input = `${source ?? ""}`;
|
|
99
98
|
const { format, ...rest } = options;
|
|
@@ -124,11 +123,6 @@ async function getPackageJson(searchPath) {
|
|
|
124
123
|
var swcConfig;
|
|
125
124
|
var tsConfig;
|
|
126
125
|
var subPathImports;
|
|
127
|
-
var ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
128
|
-
'Unknown file extension "%s"',
|
|
129
|
-
"ERR_UNKNOWN_FILE_EXTENSION"
|
|
130
|
-
);
|
|
131
|
-
var UNALLOWED_FILE_EXTENSIONS = [".tsx", ".ts", ".mts", ".cts"];
|
|
132
126
|
function isLocalPath(specifier) {
|
|
133
127
|
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file:");
|
|
134
128
|
}
|
|
@@ -169,20 +163,11 @@ var resolve = async (specifier, context, nextResolve) => {
|
|
|
169
163
|
specifier = resolvedPaths[0];
|
|
170
164
|
}
|
|
171
165
|
}
|
|
172
|
-
const allowArbitraryExtensions = !!tsConfig?.compilerOptions?.allowArbitraryExtensions;
|
|
173
|
-
if (!allowArbitraryExtensions) {
|
|
174
|
-
if (isLocalPath(specifier)) {
|
|
175
|
-
const fileExtension = extname(specifier);
|
|
176
|
-
if (UNALLOWED_FILE_EXTENSIONS.includes(fileExtension) && context.parentURL) {
|
|
177
|
-
throw new ERR_UNKNOWN_FILE_EXTENSION([fileExtension]);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
166
|
debug_default("resolving file with specifier %s", specifier);
|
|
182
167
|
try {
|
|
183
168
|
return await nextResolve(specifier, context);
|
|
184
169
|
} catch (error) {
|
|
185
|
-
if (!allowArbitraryExtensions && error.code === "ERR_MODULE_NOT_FOUND" && isLocalPath(specifier)) {
|
|
170
|
+
if (!tsConfig?.compilerOptions?.allowArbitraryExtensions && error.code === "ERR_MODULE_NOT_FOUND" && isLocalPath(specifier)) {
|
|
186
171
|
const fileExtension = extname(specifier);
|
|
187
172
|
if (fileExtension === ".js") {
|
|
188
173
|
specifier = specifier.replace(".js", ".ts");
|
|
@@ -208,7 +193,7 @@ var load = async function load2(url, context, nextLoad) {
|
|
|
208
193
|
...context,
|
|
209
194
|
format: "module"
|
|
210
195
|
});
|
|
211
|
-
const { code, map } = transformSync(source.toString(), {
|
|
196
|
+
const { code, map } = await transformSync(source.toString(), {
|
|
212
197
|
format: format ?? "module-tsx",
|
|
213
198
|
filename: fileURLToPath3(url),
|
|
214
199
|
...swcConfig
|
package/build/src/transform.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import { Config as SwcConfig } from '@swc/core';
|
|
|
5
5
|
export declare function transformSync(source: string, options: SwcConfig & {
|
|
6
6
|
filename: string;
|
|
7
7
|
format: 'module-typescript' | 'commonjs-typescript' | 'module-tsx';
|
|
8
|
-
}): import("@swc/types").Output
|
|
8
|
+
}): Promise<import("@swc/types").Output>;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppinss/ts-exec",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"files": [
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"typescript": "^5.7.2"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@poppinss/exception": "^1.2.1",
|
|
56
55
|
"@swc/core": "^1.11.24",
|
|
57
56
|
"get-tsconfig": "^4.10.0",
|
|
58
57
|
"resolve-pkg-maps": "^1.0.0"
|
|
@@ -121,8 +120,5 @@
|
|
|
121
120
|
"tests/**"
|
|
122
121
|
]
|
|
123
122
|
},
|
|
124
|
-
"prettier": "@adonisjs/prettier-config"
|
|
125
|
-
"volta": {
|
|
126
|
-
"node": "24.0.0"
|
|
127
|
-
}
|
|
123
|
+
"prettier": "@adonisjs/prettier-config"
|
|
128
124
|
}
|