-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70858d6
commit 1f2c00f
Showing
6 changed files
with
168 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Define the directory to start the search | ||
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 | ||
done | ||
|
||
# Remove all backup files | ||
find "$root_directory" -type f -name "*.bak" -exec rm {} + | ||
|
||
echo -e "\nCreating package.json file in $root_directory" | ||
# Create a package.json file to indicate that this is an ESM package | ||
echo '{ "type": "module" }' > "$root_directory/package.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.