Skip to content

Commit

Permalink
Build: Make Migrate properly recognized as a CommonJS module in Node.js
Browse files Browse the repository at this point in the history
PR gh-512 added the `"type": "module"` field to the top-level `package.json`,
making Node-based workflows fail when trying to require Migrate as it's not
exposed as ESM. To fix this, add a small `package.json` with just
`"type": "commonjs"`. Also, add Node.js smoke tests as the simplest way to
verify this change.

Fixes gh-523
Closes gh-525
Ref gh-512
  • Loading branch information
mgol authored Jul 16, 2024
1 parent 3f35988 commit 785943d
Show file tree
Hide file tree
Showing 6 changed files with 498 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@ env:
NODE_VERSION: 20.x

jobs:
node-smoke-test:
runs-on: ubuntu-latest
name: Node smoke tests
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
- name: Install dependencies
run: npm install

- name: Run Node smoke tests
run: npm run test:node_smoke_tests

test:
runs-on: ubuntu-latest
name: ${{ matrix.MIGRATE_VERSION }} - jQuery ${{ matrix.JQUERY_VERSION }} (Chrome/Firefox)
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ CDN
.sizecache.json
.eslintcache

/dist
# Ignore built files in `dist` folder
# Leave package.json
/dist/*
!/dist/package.json

/external
/node_modules

Expand Down
3 changes: 3 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
Loading

0 comments on commit 785943d

Please sign in to comment.