Skip to content

Commit

Permalink
add step to test importing the package as cjs and esm
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt committed May 20, 2024
1 parent 302e666 commit e8ea432
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/main.pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ jobs:
run: |
yarn test ${t:+-t ${t}} ${m:+-m ${m}} ${{ matrix.args }}
- name: Test importing
continue-on-error: true
if: ${{ steps.source_files_changed.outputs.any_modified == 'true' && matrix.target != 'src' }}
env:
t: "${{ matrix.target }}"
m: "${{ matrix.module }}"
run: |
set -x;
targetdir="./targets${t:+/${t}}${m:+/${m}}";
pkg_name="$(jq -r '.name' "${targetdir}/package.json")";
npm link -g "${targetdir}";
cd /;
# Attempt to import as CommonJS
node -e "require('${pkg_name}')" || true;
# Attempt to import as ESModule
node --input-type=module -e "import '${pkg_name}'" || true;
test-tree-shaking-pull-request:
needs:
- build-and-test-pull-request
Expand Down

0 comments on commit e8ea432

Please sign in to comment.