ts-arc 1.2.1 → 1.2.3

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.
Files changed (2) hide show
  1. package/dist/loader.js +17 -11
  2. 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 as = u.searchParams.get("as");
313
+ if (!as) {
314
+ throw "Copycat file URI is missing the `as` searchparam.";
315
+ }
316
+ const virtual = u.pathname;
317
+ const asPath = path.resolve(as);
318
+ const identity = url.pathToFileURL(
319
+ path.resolve(virtual)
320
+ ).href;
321
+ const out = new URL(identity);
322
+ out.searchParams.set("as", asPath);
311
323
  return {
312
- url: specifier,
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("copycat://")) {
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
- 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
- }
390
+ if (!real) throw new Error("Copycat file uri missing real path");
391
+ const code = fs.readFileSync(u.pathname, "utf8");
386
392
  return {
387
393
  format: "module",
388
- source: rawSource,
394
+ source: code,
389
395
  shortCircuit: true
390
396
  };
391
397
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-arc",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",