ts-arc 1.2.0 → 1.2.2
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 +17 -11
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -308,8 +308,20 @@ async function resolve2(specifier, context, nextResolve) {
|
|
|
308
308
|
parentPath = path.dirname(url.fileURLToPath(context.parentURL));
|
|
309
309
|
}
|
|
310
310
|
if (specifier.startsWith("copycat://")) {
|
|
311
|
+
const u = new URL(specifier);
|
|
312
|
+
const real = u.searchParams.get("real");
|
|
313
|
+
if (!real) {
|
|
314
|
+
throw "Copycat file URI is missing the `real` searchparam.";
|
|
315
|
+
}
|
|
316
|
+
const virtual = u.pathname;
|
|
317
|
+
const realPath = path.resolve(real);
|
|
318
|
+
const identity = url.pathToFileURL(
|
|
319
|
+
path.resolve(virtual)
|
|
320
|
+
).href;
|
|
321
|
+
const out = new URL(identity);
|
|
322
|
+
out.searchParams.set("real", realPath);
|
|
311
323
|
return {
|
|
312
|
-
url:
|
|
324
|
+
url: out.href,
|
|
313
325
|
shortCircuit: true
|
|
314
326
|
};
|
|
315
327
|
}
|
|
@@ -372,20 +384,14 @@ async function load(urlStr, context, nextLoad) {
|
|
|
372
384
|
});
|
|
373
385
|
}
|
|
374
386
|
function loadSync(urlStr, context, nextLoadSync) {
|
|
375
|
-
if (urlStr.startsWith("
|
|
387
|
+
if (urlStr.startsWith("file://") && urlStr.includes("real=")) {
|
|
376
388
|
const u = new URL(urlStr);
|
|
377
389
|
const real = u.searchParams.get("real");
|
|
378
|
-
if (!real)
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
const filePath = path.resolve(real);
|
|
382
|
-
let rawSource = fs.readFileSync(filePath, "utf8");
|
|
383
|
-
if (config.emitDecoratorMetadata) {
|
|
384
|
-
rawSource = addMetadataDecorators(rawSource);
|
|
385
|
-
}
|
|
390
|
+
if (!real) throw new Error("Copycat file uri missing real path");
|
|
391
|
+
const code = fs.readFileSync(real, "utf8");
|
|
386
392
|
return {
|
|
387
393
|
format: "module",
|
|
388
|
-
source:
|
|
394
|
+
source: code,
|
|
389
395
|
shortCircuit: true
|
|
390
396
|
};
|
|
391
397
|
}
|