Skip to content

Commit

Permalink
Replace all import paths in runtime files .js -> .mjs
Browse files Browse the repository at this point in the history
We rename the extension when copying runtime js files over, so we need
to massage the imports/exports to comply.
  • Loading branch information
gregsexton committed Jan 26, 2024
1 parent ed755e1 commit 5a64ef9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions sknpm/src/main.sk
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ fun copyAndConvertImport(
optCategory: ?String = None();
lines = contents.split("\n").map(line -> {
if (line.startsWith("import ") || line.startsWith("export {")) {
!line = line.replace(".js", ".mjs");
elements = line.split(" from ");
if (elements.size() == 2) {
imported = elements[1].split("\"");
Expand All @@ -916,11 +917,7 @@ fun copyAndConvertImport(
size = elems.size();
if (size > 1 && elems[0].startsWith("#")) {
!elems = elems.mapWithIndex((idx, v) ->
if (idx == 0) "." else if (idx == size - 1) {
`${v}.mjs`
} else {
v
}
if (idx == 0) "." else v
);
!line = `${elements[0]} from "${elems.join("/")}"`
}
Expand Down

0 comments on commit 5a64ef9

Please sign in to comment.