Skip to content

Commit

Permalink
Allow Rollup to bundle browser dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Dec 11, 2023
1 parent 550a32e commit 525b54b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/govuk-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
"@babel/core": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"autoprefixer": "^10.4.16",
Expand Down
12 changes: 11 additions & 1 deletion packages/govuk-frontend/rollup.publish.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import config from '@govuk-frontend/config'
import { babel } from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import { defineConfig } from 'rollup'

Expand Down Expand Up @@ -54,15 +56,23 @@ export default defineConfig(({ i: input }) => ({
* Input plugins
*/
plugins: [
resolve({
browser: true
}),
replace({
include: '**/common/govuk-frontend-version.mjs',
preventAssignment: true,

// Add GOV.UK Frontend release version
development: config.version
}),
commonjs({
requireReturnsDefault: 'preferred',
defaultIsModuleExports: true
}),
babel({
babelHelpers: 'bundled'
babelHelpers: 'bundled',
exclude: '**/node_modules/**'
})
]
}))
12 changes: 11 additions & 1 deletion packages/govuk-frontend/rollup.release.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import config from '@govuk-frontend/config'
import { babel } from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import terser from '@rollup/plugin-terser'
import * as GOVUKFrontend from 'govuk-frontend/src/govuk/all.mjs'
Expand Down Expand Up @@ -54,15 +56,23 @@ export default defineConfig(({ i: input }) => ({
* Input plugins
*/
plugins: [
resolve({
browser: true
}),
replace({
include: '**/common/govuk-frontend-version.mjs',
preventAssignment: true,

// Add GOV.UK Frontend release version
development: config.version
}),
commonjs({
requireReturnsDefault: 'preferred',
defaultIsModuleExports: true
}),
babel({
babelHelpers: 'bundled'
babelHelpers: 'bundled',
exclude: '**/node_modules/**'
})
]
}))

0 comments on commit 525b54b

Please sign in to comment.