Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix package resolution in Node.js 17+ for support/4.x #3817

Merged
merged 4 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,55 @@ jobs:
- name: Run verify task
run: ${{ matrix.task.run }}

package:
name: Export ${{ matrix.conditions }}, Node.js ${{ matrix.node-version }}
runs-on: ${{ github.event.inputs.runner || 'ubuntu-latest' }}
needs: [install]

# Skip when scheduled or run manually
if: ${{ !inputs.runner }}

strategy:
fail-fast: false

matrix:
node-version:
- 12.18 # Node.js 12.18 uses package exports with trailing slashes
- 12 # But Node.js 12.20+ uses package exports with subpath patterns
- 18

conditions:
- require
- import

exclude:
- conditions: import
node-version: 12.18

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Restore dependencies
uses: ./.github/workflows/actions/install-node

- name: Change Node.js version
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Export ${{ matrix.conditions }}, Node.js ${{ matrix.node-version }}
env:
# Node.js conditions override from "require" to "import" etc
# https://nodejs.org/api/cli.html#-c-condition---conditionscondition
FLAGS: ${{ matrix.conditions != 'require' && format(' --conditions {0}', matrix.conditions) || '' }}

run: |
node --eval "console.log(require.resolve('govuk-frontend'))"${{ env.FLAGS }}
node --eval "console.log(require.resolve('govuk-frontend/package.json'))"${{ env.FLAGS }}
node --eval "console.log(require.resolve('govuk-frontend/govuk/i18n.js'))"${{ env.FLAGS }}
node --eval "console.log(require.resolve('govuk-frontend/govuk-esm/i18n.mjs'))"${{ env.FLAGS }}

regression:
name: Percy
needs: [install, build]
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### Fixes

We’ve made fixes to GOV.UK Frontend in the following pull requests:

- [#3817: Fix package resolution in Node.js 17+](https://github.com/alphagov/govuk-frontend/pull/3817)

## 4.6.0 (Feature release)

### New features
Expand Down
4 changes: 3 additions & 1 deletion package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
"version": "4.6.0",
"main": "govuk/all.js",
"module": "govuk-esm/all.mjs",
"sass": "govuk/all.scss",
"exports": {
".": {
"sass": "./govuk/all.scss",
"import": "./govuk-esm/all.mjs",
"require": "./govuk/all.js"
},
"./govuk/": "./govuk/",
"./govuk/*": "./govuk/*",
"./govuk-esm/": "./govuk-esm/",
"./govuk-esm/*": "./govuk-esm/*",
"./package.json": "./package.json"
},
"sideEffects": [
"govuk-esm/vendor/**"
],
"sass": "govuk/all.scss",
"engines": {
"node": ">= 4.2.0"
},
Expand Down