Skip to content

Commit

Permalink
build: new libESM to use ES module
Browse files Browse the repository at this point in the history
  • Loading branch information
karliatto committed Jan 31, 2025
1 parent a56381e commit d23f355
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .easignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ test-results

lib
libDev
libESM
dist
public
coverage
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ playwright-report
# build outputs
lib
libDev
libESM
dist
public
coverage
Expand Down
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test-results

lib
libDev
libESM
dist
public
coverage
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ __pycache__/
# build outputs
lib
libDev
libESM
dist
public
coverage
Expand Down
29 changes: 28 additions & 1 deletion scripts/replace-imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,34 @@

set -euxo pipefail

REGEX="s/@trezor\/([^/]+)\/src/@trezor\/\1\/lib/g"
# Usage:
# bash replace-imports.sh <directory> [lib-type]
#
# Arguments:
# <directory> The path to the directory containing files to modify.
# [lib-type] (Optional) The type of library to use. Defaults to "lib" if not provided.
# Use "libESM" for ESM libraries.
#
# Example:
# To replace imports in the ./lib directory using the default library type:
# bash replace-imports.sh ./lib
#
# To replace imports in the ./libESM directory using the "libESM" library type:
# bash replace-imports.sh ./libESM libESM

# By default set to "lib" but when providing second argument it uses it.
if [ $# -ge 2 ]; then
LIB_TYPE="$2"
else
LIB_TYPE="lib"
fi

# Set the regex based on the LIB_TYPE argument
if [[ "$LIB_TYPE" == "libESM" ]]; then
REGEX="s/@trezor\/([^/]+)\/src/@trezor\/\1\/libESM/g"
else
REGEX="s/@trezor\/([^/]+)\/src/@trezor\/\1\/lib/g"
fi

# Determine the operating system
OS="$(uname)"
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"exclude": [
"**/node_modules",
"**/lib",
"**/libESM",
"**/libDev",
"**/build",
"**/build-electron",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"exclude": [
"**/node_modules",
"**/lib",
"**/libESM",
"**/libDev",
"**/build",
"**/build-electron",
Expand Down

0 comments on commit d23f355

Please sign in to comment.