diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 857b4122d3..8d198e55c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -204,6 +204,58 @@ 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, build] + + # 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: Restore build + uses: ./.github/workflows/actions/build + + - 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/dist/govuk/i18n.js'))"${{ env.FLAGS }} + node --eval "console.log(require.resolve('govuk-frontend/dist/govuk-esm/i18n.mjs'))"${{ env.FLAGS }} + regression: name: Percy needs: [install, build]