Skip to content

Commit 3bb232d

Browse files
authored
fix: fix cjs distribution artifacts (#100)
1 parent 5949604 commit 3bb232d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

babel.config.cjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ module.exports = {
3030
{
3131
resolvePath(sourcePath, currentFile) {
3232
if (sourcePath === "apg-lite") {
33-
const apgLiteCJS = path.resolve("./src/apg-lite.cjs");
33+
// apg-lite.cjs will be in the same cjs/ output directory
34+
// The relative path from src/ needs to account for the output being in cjs/
35+
const srcDir = path.resolve("./src");
3436
const currentDir = path.dirname(currentFile);
35-
return path.relative(currentDir, apgLiteCJS);
37+
const relativeToSrc = path.relative(srcDir, currentDir);
38+
// Path from the output file location to apg-lite.cjs
39+
// Both will be under cjs/, so we need to go up relativeToSrc levels then to apg-lite.cjs
40+
if (relativeToSrc === "") {
41+
return "./apg-lite.cjs";
42+
}
43+
const depth = relativeToSrc.split(path.sep).length;
44+
return "../".repeat(depth) + "apg-lite.cjs";
3645
}
3746
return sourcePath;
3847
},

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)