Skip to content

Commit

Permalink
Change GitHub release JavaScript to ES modules
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jul 5, 2023
1 parent 5ddbf4c commit 7c02825
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions packages/govuk-frontend/rollup.release.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import replace from '@rollup/plugin-replace'
import terser from '@rollup/plugin-terser'
import * as GOVUKFrontend from 'govuk-frontend/src/govuk/all.mjs'
import { pkg } from 'govuk-frontend-config'
import { componentPathToModuleName } from 'govuk-frontend-lib/names'
import { defineConfig } from 'rollup'

/**
* Rollup config for GitHub release
*
* Universal Module Definition (UMD) bundle for browser <script>
* `window` globals and compatibility with CommonJS and AMD `require()`
* ECMAScript (ES) module bundles for browser <script type="module">
* or using `import` for modern browsers and Node.js scripts
*/
export default defineConfig(({ i: input }) => ({
input,
Expand All @@ -19,7 +18,7 @@ export default defineConfig(({ i: input }) => ({
*/
output: {
compact: true,
format: 'umd',
format: 'es',

// Bundled modules
preserveModules: false,
Expand All @@ -41,11 +40,7 @@ export default defineConfig(({ i: input }) => ({
// Compatibility workarounds
safari10: true
})
],

// Components are given names (e.g window.GOVUKFrontend.Accordion)
amd: { id: componentPathToModuleName(input) },
name: componentPathToModuleName(input)
]
},

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/govuk-frontend/tasks/build/release.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('dist/', () => {
})

it('should contain correct version number', () => {
expect(javascript).toContain(`.version="${pkg.version}"`)
expect(javascript).toContain(`const version="${pkg.version}"`)
})

it('should contain source mapping URL', () => {
Expand Down

0 comments on commit 7c02825

Please sign in to comment.