diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4931d49f87..df1eb6a573 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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] diff --git a/CHANGELOG.md b/CHANGELOG.md index e5413f02e3..17182ab346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package/package.json b/package/package.json index c078c0ec34..b155532760 100644 --- a/package/package.json +++ b/package/package.json @@ -4,6 +4,7 @@ "version": "4.6.0", "main": "govuk/all.js", "module": "govuk-esm/all.mjs", + "sass": "govuk/all.scss", "exports": { ".": { "sass": "./govuk/all.scss", @@ -11,13 +12,14 @@ "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" },