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

[SPIKE] Add bundled-only "browser" package exports #3920

Closed
wants to merge 3 commits into from
Closed
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
21 changes: 11 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jobs:
run: ${{ matrix.task.run }}

package:
name: Export ${{ matrix.conditions }}, Node.js ${{ matrix.node-version }}
name: Export ${{ join(matrix.conditions, ' ') || 'require' }}, Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
needs: [install, build]

Expand All @@ -241,22 +241,23 @@ jobs:

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
- 12 # Node.js 12.20+ uses package exports with subpath patterns
- 18 # Node.js 17+ cannot use package exports with trailing slashes

conditions:
- require
- import
- [require]
- [import]
- [browser, require]
- [browser, import]

exclude:
- conditions: import
node-version: 12.18
include:
- conditions: []
node-version: 12.18 # Node.js 12.18 uses package exports with trailing slashes

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) || '' }}
FLAGS: ${{ matrix.conditions[0] != null && format(' --conditions {0}', join(matrix.conditions, ' --conditions ')) || '' }}

steps:
- name: Checkout
Expand Down
6 changes: 6 additions & 0 deletions packages/govuk-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
],
"exports": {
".": {
"browser": {
"sass": "./dist/govuk/all.scss",
"import": "./dist/govuk/all.bundle.mjs",
"require": "./dist/govuk/all.bundle.js",
"default": "./dist/govuk/all.bundle.js"
},
"sass": "./dist/govuk/all.scss",
"import": "./dist/govuk/all.mjs",
"require": "./dist/govuk/all.bundle.js",
Expand Down