ts-arc 1.3.0 → 1.3.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.
Files changed (2) hide show
  1. package/dist/loader.js +9 -13
  2. package/package.json +1 -1
package/dist/loader.js CHANGED
@@ -309,12 +309,7 @@ async function resolve2(specifier, context, nextResolve) {
309
309
  if (parentUrl.protocol === "file:") {
310
310
  parentPath = path.dirname(url.fileURLToPath(parentUrl));
311
311
  } else if (parentUrl.protocol === "copycat:") {
312
- const as = parentUrl.searchParams.get("as");
313
- if (as && typeof as === "string") {
314
- parentPath = path.dirname(as);
315
- } else {
316
- parentPath = process.cwd();
317
- }
312
+ parentPath = path.dirname(parentUrl.pathname);
318
313
  } else {
319
314
  parentPath = process.cwd();
320
315
  }
@@ -325,11 +320,11 @@ async function resolve2(specifier, context, nextResolve) {
325
320
  if (!real) {
326
321
  throw new Error("Copycat file URI is missing the `real` searchparam.");
327
322
  }
328
- const realPath = path.resolve(real);
329
- const out = new URL(specifier);
330
- out.pathname = realPath;
331
- out.searchParams.set("real", realPath);
323
+ const pretendPath = path.resolve(u.pathname);
324
+ const fileUrl = url.pathToFileURL(pretendPath).href;
325
+ const out = new URL(fileUrl);
332
326
  out.searchParams.set("copycat", "true");
327
+ out.searchParams.set("real", real);
333
328
  return {
334
329
  url: out.href,
335
330
  shortCircuit: true
@@ -396,11 +391,12 @@ async function load(urlStr, context, nextLoad) {
396
391
  function loadSync(urlStr, context, nextLoadSync) {
397
392
  const u = new URL(urlStr);
398
393
  if (u.searchParams.has("copycat")) {
399
- const real = u.searchParams.get("real");
400
- if (!real) {
394
+ const realEncoded = u.searchParams.get("real");
395
+ if (!realEncoded) {
401
396
  throw new Error("Copycat file URI is missing the `real` searchparam.");
402
397
  }
403
- const code = fs.readFileSync(decodeURI(real), "utf8");
398
+ const realPath = decodeURIComponent(realEncoded);
399
+ const code = fs.readFileSync(realPath, "utf8");
404
400
  return {
405
401
  format: "module",
406
402
  source: code,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-arc",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",