ts-arc 1.3.1 → 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.
- package/dist/loader.js +8 -7
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -320,11 +320,11 @@ async function resolve2(specifier, context, nextResolve) {
|
|
|
320
320
|
if (!real) {
|
|
321
321
|
throw new Error("Copycat file URI is missing the `real` searchparam.");
|
|
322
322
|
}
|
|
323
|
-
const
|
|
324
|
-
const
|
|
325
|
-
out
|
|
326
|
-
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);
|
|
327
326
|
out.searchParams.set("copycat", "true");
|
|
327
|
+
out.searchParams.set("real", real);
|
|
328
328
|
return {
|
|
329
329
|
url: out.href,
|
|
330
330
|
shortCircuit: true
|
|
@@ -391,11 +391,12 @@ async function load(urlStr, context, nextLoad) {
|
|
|
391
391
|
function loadSync(urlStr, context, nextLoadSync) {
|
|
392
392
|
const u = new URL(urlStr);
|
|
393
393
|
if (u.searchParams.has("copycat")) {
|
|
394
|
-
const
|
|
395
|
-
if (!
|
|
394
|
+
const realEncoded = u.searchParams.get("real");
|
|
395
|
+
if (!realEncoded) {
|
|
396
396
|
throw new Error("Copycat file URI is missing the `real` searchparam.");
|
|
397
397
|
}
|
|
398
|
-
const
|
|
398
|
+
const realPath = decodeURIComponent(realEncoded);
|
|
399
|
+
const code = fs.readFileSync(realPath, "utf8");
|
|
399
400
|
return {
|
|
400
401
|
format: "module",
|
|
401
402
|
source: code,
|