Skip to content

Commit

Permalink
Use Perl
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz committed Mar 9, 2024
1 parent 7db647e commit 9077ce3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/rename-esm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ for file in dist/esm/*.js; do

# Replace the sourceMappingURL to point to the new `.mjs.map` file.
sourceMap=$(basename "${file%.js}.mjs.map")
sed -i '' "s|//# sourceMappingURL=.*\.js\.map|//# sourceMappingURL=$sourceMap|" "${file%.js}.mjs"
perl -i -pe "s|//# sourceMappingURL=.*?\.js\.map|//# sourceMappingURL=$sourceMap|" "${file%.js}.mjs"
done

for file in dist/esm/*.js.map; do
# Rename the `.js.map` files to `.mjs.map`.
mv "$file" "${file%.js.map}.mjs.map"

# Replace the file references in the source map to point to the new `.mjs` file.
sed -i '' 's/\.js/\.mjs/g' "${file%.js.map}.mjs.map"
perl -i -pe 's/\.js/\.mjs/g' "${file%.js.map}.mjs.map"
done

0 comments on commit 9077ce3

Please sign in to comment.