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