Skip to content

Commit

Permalink
Merge pull request #168 from ilovepixelart/feature/esm-bash-and-dep
Browse files Browse the repository at this point in the history
ESM bash and Dep
  • Loading branch information
ilovepixelart authored Jan 9, 2024
2 parents 88c418c + 106e562 commit c57462e
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 1,014 deletions.
1 change: 1 addition & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"[javascript]": {
"editor.tabSize": 2,
Expand Down
6 changes: 3 additions & 3 deletions bash/esm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ root_directory="dist/esm"
echo "Adding .js extension to relative imports in files:"
# Find all JavaScript files and iterate through them and add the .js extension to relative imports
find "$root_directory" -type f -name "*.js" | while read -r file; do
if awk '!/export {};|\/\/# sourceMappingURL:|^[[:space:]]*\/\//' "$file" | grep -q "import .* from '[.]\{0,2\}\/[^']*'"; then
sed -i.bak -E "s/(import .* from '[.]{0,2}\/[^']*)'/\1.js'/g" "$file" && echo "- $file"
fi
sed -i.bak -E "s/(import .* from '[.]{0,2}\/[^']*)'/\1.js'/g" "$file"
sed -i.bak -E "s/(import \* as .* from '[.]{0,2}\/[^']*)'/\1.js'/g" "$file"
sed -i.bak -E "s/(export \* as .* from '[.]{0,2}\/[^']*)'/\1.js'/g" "$file"
done

# Remove all backup files
Expand Down
Loading

0 comments on commit c57462e

Please sign in to comment.