ts-arc 1.2.6 → 1.2.7

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 +11 -8
  2. package/package.json +1 -1
package/dist/loader.js CHANGED
@@ -381,16 +381,19 @@ async function load(urlStr, context, nextLoad) {
381
381
  });
382
382
  }
383
383
  function loadSync(urlStr, context, nextLoadSync) {
384
- if (urlStr.startsWith("copycat://")) {
384
+ {
385
385
  const u = new URL(urlStr);
386
- const filePath = u.pathname.startsWith("/") ? u.pathname.slice(1) : u.pathname;
386
+ const isCopycat = u.searchParams.get("copycat") === "1";
387
387
  const asPath = u.searchParams.get("as");
388
- const code = fs.readFileSync(asPath || filePath, "utf8");
389
- return {
390
- format: "module",
391
- source: code,
392
- shortCircuit: true
393
- };
388
+ const filePath = url.fileURLToPath(u.origin + u.pathname);
389
+ const code = fs.readFileSync(filePath, "utf8");
390
+ if (isCopycat) {
391
+ return {
392
+ format: "module",
393
+ source: code,
394
+ shortCircuit: true
395
+ };
396
+ }
394
397
  }
395
398
  if (urlStr.endsWith(".ts") || urlStr.endsWith(".tsx")) {
396
399
  const esbuildLoader = urlStr.endsWith(".tsx") ? "tsx" : "ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-arc",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",