-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: better support for ESM imports (#850)
* feat: supporting esm import (#824) * feat: supporting esm import add the exports in package.json to support esm import for js and ts * feat: support for .js module export adding the support for .js module exports and support for types, nextjs, framework and recipe module exports * test: add a test to check our export mapping * fix: update export mapping * chore: update version number * chore: add new related checklist item to PR template * fix: remove unnecessary/broken entry point * test: add explanation comment --------- Co-authored-by: Anurag Srivastava <[email protected]>
- Loading branch information
1 parent
fb3ffa7
commit 2f25f2f
Showing
13 changed files
with
140 additions
and
23 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ releasePassword | |
.tmp | ||
.idea | ||
/test_report | ||
/temp_test_exports | ||
/temp_* | ||
/.nyc_output |
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 |
---|---|---|
|
@@ -18,4 +18,5 @@ examples/ | |
add-ts-no-check.js | ||
docs/ | ||
.prettierignore | ||
updateLibInExample | ||
updateLibInExample | ||
testExports.sh |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
#!/bin/sh | ||
|
||
TEST_PROJECT_DIR=./temp_test_exports | ||
|
||
mkdir -p $TEST_PROJECT_DIR | ||
|
||
npm pack || exit $? | ||
|
||
mv supertokens-node-*.tgz $TEST_PROJECT_DIR | ||
cd $TEST_PROJECT_DIR | ||
|
||
npm init -y || exit $? | ||
|
||
rm -f index.mjs | ||
touch index.mjs | ||
# We test that all JS files we publish are importable without an extension | ||
tar -t -f ./supertokens-node* | grep \\.js$ | sed 's/^package\/\(.*\)\.js$/import \"supertokens-node\/\1\";/' >> index.mjs | ||
# We test that all JS files we publish are importable with the JS extension | ||
tar -t -f ./supertokens-node* | grep \\.js$ | sed 's/^package\/\(.*\)\.js$/import \"supertokens-node\/\1\.js";/' >> index.mjs | ||
# We test that all folders that have an index.js (outside of /lib/build) are importable as folders. | ||
tar -t -f --exclude package/lib/build ./supertokens-node* | grep package/.*/index\\.js$ | sed 's/^package\/\(.*\)\/index\.js$/import \"supertokens-node\/\1\";/' >> index.mjs | ||
# We also test that the sdk itself is importable | ||
echo 'import "supertokens-node";' >> index.mjs | ||
|
||
mkdir -p node_modules/supertokens-node | ||
|
||
tar -xvvf supertokens-node-*.tgz --strip-components=1 -C node_modules/supertokens-node package | ||
|
||
node index.mjs | ||
EXIT_CODE=$? | ||
|
||
cd .. | ||
rm -rf $TEST_PROJECT_DIR | ||
exit $EXIT_CODE | ||
|