ts-arc 1.2.7 → 1.2.8
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/loader.js +18 -18
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -309,14 +309,15 @@ async function resolve2(specifier, context, nextResolve) {
|
|
|
309
309
|
}
|
|
310
310
|
if (specifier.startsWith("copycat://")) {
|
|
311
311
|
const u = new URL(specifier);
|
|
312
|
-
const
|
|
313
|
-
if (!
|
|
314
|
-
throw new Error("Copycat file URI is missing the `
|
|
312
|
+
const real = u.searchParams.get("real");
|
|
313
|
+
if (!real) {
|
|
314
|
+
throw new Error("Copycat file URI is missing the `real` searchparam.");
|
|
315
315
|
}
|
|
316
|
-
const
|
|
316
|
+
const realPath = path.resolve(real);
|
|
317
317
|
const out = new URL(specifier);
|
|
318
|
-
out.pathname =
|
|
319
|
-
out.searchParams.set("
|
|
318
|
+
out.pathname = realPath;
|
|
319
|
+
out.searchParams.set("real", realPath);
|
|
320
|
+
out.searchParams.set("copycat", "true");
|
|
320
321
|
return {
|
|
321
322
|
url: out.href,
|
|
322
323
|
shortCircuit: true
|
|
@@ -381,19 +382,18 @@ async function load(urlStr, context, nextLoad) {
|
|
|
381
382
|
});
|
|
382
383
|
}
|
|
383
384
|
function loadSync(urlStr, context, nextLoadSync) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const code = fs.readFileSync(filePath, "utf8");
|
|
390
|
-
if (isCopycat) {
|
|
391
|
-
return {
|
|
392
|
-
format: "module",
|
|
393
|
-
source: code,
|
|
394
|
-
shortCircuit: true
|
|
395
|
-
};
|
|
385
|
+
const u = new URL(urlStr);
|
|
386
|
+
if (u.searchParams.has("copycat")) {
|
|
387
|
+
const real = u.searchParams.get("real");
|
|
388
|
+
if (!real) {
|
|
389
|
+
throw new Error("Copycat file URI is missing the `real` searchparam.");
|
|
396
390
|
}
|
|
391
|
+
const code = fs.readFileSync(decodeURI(real), "utf8");
|
|
392
|
+
return {
|
|
393
|
+
format: "module",
|
|
394
|
+
source: code,
|
|
395
|
+
shortCircuit: true
|
|
396
|
+
};
|
|
397
397
|
}
|
|
398
398
|
if (urlStr.endsWith(".ts") || urlStr.endsWith(".tsx")) {
|
|
399
399
|
const esbuildLoader = urlStr.endsWith(".tsx") ? "tsx" : "ts";
|