ts-arc 1.2.2 → 1.2.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.
- package/dist/loader.js +7 -9
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -309,17 +309,17 @@ 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 "Copycat file URI is missing the `
|
|
312
|
+
const as = u.searchParams.get("as");
|
|
313
|
+
if (!as) {
|
|
314
|
+
throw "Copycat file URI is missing the `as` searchparam.";
|
|
315
315
|
}
|
|
316
316
|
const virtual = u.pathname;
|
|
317
|
-
const
|
|
317
|
+
const asPath = path.resolve(as);
|
|
318
318
|
const identity = url.pathToFileURL(
|
|
319
319
|
path.resolve(virtual)
|
|
320
320
|
).href;
|
|
321
321
|
const out = new URL(identity);
|
|
322
|
-
out.searchParams.set("
|
|
322
|
+
out.searchParams.set("as", asPath);
|
|
323
323
|
return {
|
|
324
324
|
url: out.href,
|
|
325
325
|
shortCircuit: true
|
|
@@ -384,11 +384,9 @@ async function load(urlStr, context, nextLoad) {
|
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
function loadSync(urlStr, context, nextLoadSync) {
|
|
387
|
-
if (urlStr.startsWith("
|
|
387
|
+
if (urlStr.startsWith("copycat://")) {
|
|
388
388
|
const u = new URL(urlStr);
|
|
389
|
-
const
|
|
390
|
-
if (!real) throw new Error("Copycat file uri missing real path");
|
|
391
|
-
const code = fs.readFileSync(real, "utf8");
|
|
389
|
+
const code = fs.readFileSync(u.pathname, "utf8");
|
|
392
390
|
return {
|
|
393
391
|
format: "module",
|
|
394
392
|
source: code,
|