Skip to content

Commit

Permalink
WIP: add initAll tests
Browse files Browse the repository at this point in the history
  • Loading branch information
owenatgov committed May 1, 2024
1 parent 1f8c6ce commit bfa8449
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/bundler-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:

jobs:
test-tree-shaking:
test-tree-shaking-default:
name: Test tree shaking
runs-on: ubuntu-latest

Expand Down Expand Up @@ -38,4 +38,5 @@ jobs:
- name: Check output
working-directory: ./.github/workflows/bundler-integrations
run: |
! grep "Accordion" dist/${{matrix.bundler}}/*.js
! grep "Accordion" dist/${{matrix.bundler}}/default.js
grep "Accordion" dist/${{matrix.bundler}}/initAll.js
12 changes: 0 additions & 12 deletions .github/workflows/bundler-integrations/index.html

This file was deleted.

7 changes: 5 additions & 2 deletions .github/workflows/bundler-integrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"description": "Boilerplate to verify that GOV.UK Frontend works OK with main bundlers",
"private": true,
"scripts": {
"rollup": "rollup -c rollup.config.mjs src/index.mjs -o dist/rollup/main.js",
"webpack": "webpack ./src/index.mjs --mode production -o dist/webpack",
"rollup": "npm run rollup:default && npm run rollup:initAll",
"rollup:default": "npm run rollup:cli -- -o dist/rollup/default.js ./src/default.mjs",
"rollup:initAll": "npm run rollup:cli -- -o dist/rollup/initAll.js ./src/initAll.mjs",
"rollup:cli": "rollup -c rollup.config.mjs",
"webpack": "webpack --mode production -o dist/webpack",
"vite": "vite build",
"clean": "del-cli dist",
"build:all": "concurrently \"npm run rollup\" \"npm run webpack\" \"npm run vite\" --names \"rollup,webpack,vite\" --prefix-colors \"red.dim,blue.dim,yellow.dim\""
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/bundler-integrations/src/initAll.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { initAll } from 'govuk-frontend'

initAll()
13 changes: 13 additions & 0 deletions .github/workflows/bundler-integrations/vite.config.default.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('vite').UserConfig} */

import defaultConfig from './vite.config.mjs'

export default {
build: {
...defaultConfig.build,
rollupOptions: {
...defaultConfig.build.rollupOptions,
input: 'src/default.mjs'
}
}
}
13 changes: 13 additions & 0 deletions .github/workflows/bundler-integrations/vite.config.initAll.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('vite').UserConfig} */

import defaultConfig from './vite.config.mjs'

export default {
build: {
...defaultConfig.build,
rollupOptions: {
...defaultConfig.build.rollupOptions,
input: 'src/initAll.mjs'
}
}
}
10 changes: 9 additions & 1 deletion .github/workflows/bundler-integrations/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
/** @type {import('vite').UserConfig} */
// the default vite config used by the different test case configs

export default {
build: {
// Align output with other bundlers to facilitate testing
outDir: 'dist/vite',
assetsDir: '.',
// Prevent minification so we can see actual class/function names
minify: false
minify: false,
rollupOptions: {
input: ['./src/default.mjs', './src/initAll.mjs'],
output: {
entryFileNames: '[name].js'
}
}
}
}
9 changes: 8 additions & 1 deletion .github/workflows/bundler-integrations/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ module.exports = {
// Prevent minification so we can see what's going on in the built file
minimize: false
},
target: 'web'
target: 'web',
entry: {
default: './src/default.mjs',
initAll: './src/initAll.mjs'
},
output: {
filename: '[name].js'
}
}

0 comments on commit bfa8449

Please sign in to comment.