ts-arc 1.1.29 → 1.2.1
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 +23 -0
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -307,6 +307,12 @@ async function resolve2(specifier, context, nextResolve) {
|
|
|
307
307
|
if (context.parentURL) {
|
|
308
308
|
parentPath = path.dirname(url.fileURLToPath(context.parentURL));
|
|
309
309
|
}
|
|
310
|
+
if (specifier.startsWith("copycat://")) {
|
|
311
|
+
return {
|
|
312
|
+
url: specifier,
|
|
313
|
+
shortCircuit: true
|
|
314
|
+
};
|
|
315
|
+
}
|
|
310
316
|
if (specifier.startsWith("file://")) {
|
|
311
317
|
const filePath = url.fileURLToPath(specifier);
|
|
312
318
|
const dir = path.dirname(filePath);
|
|
@@ -366,6 +372,23 @@ async function load(urlStr, context, nextLoad) {
|
|
|
366
372
|
});
|
|
367
373
|
}
|
|
368
374
|
function loadSync(urlStr, context, nextLoadSync) {
|
|
375
|
+
if (urlStr.startsWith("copycat://")) {
|
|
376
|
+
const u = new URL(urlStr);
|
|
377
|
+
const real = u.searchParams.get("real");
|
|
378
|
+
if (!real) {
|
|
379
|
+
throw new Error("copycat:// missing real source path");
|
|
380
|
+
}
|
|
381
|
+
const filePath = path.resolve(real);
|
|
382
|
+
let rawSource = fs.readFileSync(filePath, "utf8");
|
|
383
|
+
if (config.emitDecoratorMetadata) {
|
|
384
|
+
rawSource = addMetadataDecorators(rawSource);
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
format: "module",
|
|
388
|
+
source: rawSource,
|
|
389
|
+
shortCircuit: true
|
|
390
|
+
};
|
|
391
|
+
}
|
|
369
392
|
if (urlStr.endsWith(".ts") || urlStr.endsWith(".tsx")) {
|
|
370
393
|
const esbuildLoader = urlStr.endsWith(".tsx") ? "tsx" : "ts";
|
|
371
394
|
const filePath = url.fileURLToPath(urlStr);
|