Skip to content

Commit

Permalink
ESM bash and Dep
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovepixelart committed Jan 5, 2024
1 parent ca0e4d2 commit d6851db
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 973 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 d6851db

Please sign in to comment.