ts-arc 1.2.4 → 1.2.6
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 +6 -7
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -311,14 +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
|
-
const virtual = u.pathname;
|
|
317
316
|
const asPath = path.resolve(as);
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
).href;
|
|
321
|
-
const out = new URL(identity);
|
|
317
|
+
const out = new URL(specifier);
|
|
318
|
+
out.pathname = asPath;
|
|
322
319
|
out.searchParams.set("as", asPath);
|
|
323
320
|
return {
|
|
324
321
|
url: out.href,
|
|
@@ -386,7 +383,9 @@ async function load(urlStr, context, nextLoad) {
|
|
|
386
383
|
function loadSync(urlStr, context, nextLoadSync) {
|
|
387
384
|
if (urlStr.startsWith("copycat://")) {
|
|
388
385
|
const u = new URL(urlStr);
|
|
389
|
-
const
|
|
386
|
+
const filePath = u.pathname.startsWith("/") ? u.pathname.slice(1) : u.pathname;
|
|
387
|
+
const asPath = u.searchParams.get("as");
|
|
388
|
+
const code = fs.readFileSync(asPath || filePath, "utf8");
|
|
390
389
|
return {
|
|
391
390
|
format: "module",
|
|
392
391
|
source: code,
|