-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3726 from alphagov/module-default
Default to ES modules with single Rollup config
- Loading branch information
Showing
30 changed files
with
290 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,12 @@ | ||
import { join } from 'path' | ||
|
||
import { npm, scripts, task } from 'govuk-frontend-tasks' | ||
import { npm } from 'govuk-frontend-tasks' | ||
import gulp from 'gulp' | ||
|
||
/** | ||
* JavaScripts task (for watch) | ||
* Compilation, documentation | ||
* Documentation | ||
* | ||
* @type {import('govuk-frontend-tasks').TaskFunction} | ||
*/ | ||
export const compile = (options) => gulp.series( | ||
task.name('compile:js', () => | ||
scripts.compile('all.mjs', { | ||
...options, | ||
|
||
srcPath: join(options.srcPath, 'javascripts'), | ||
destPath: join(options.destPath, 'javascripts'), | ||
configPath: join(options.basePath, 'rollup.config.mjs'), | ||
|
||
// Rename with `*.bundle.min.mjs` extension | ||
filePath ({ dir, name }) { | ||
return join(dir, `${name}.bundle.min.mjs`) | ||
} | ||
}) | ||
), | ||
|
||
// Build JSDoc for /docs/javascript | ||
npm.script('build:jsdoc', [], options) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import replace from '@rollup/plugin-replace' | ||
import { pkg } from 'govuk-frontend-config' | ||
import { componentPathToModuleName } from 'govuk-frontend-lib/names' | ||
import { defineConfig } from 'rollup' | ||
|
||
/** | ||
* Rollup config for npm publish | ||
*/ | ||
export default defineConfig(({ i: input }) => ({ | ||
input, | ||
|
||
/** | ||
* Output options | ||
*/ | ||
output: [ | ||
/** | ||
* ECMAScript (ES) modules for Node.js or bundler `import` | ||
*/ | ||
{ | ||
entryFileNames: '[name].mjs', | ||
format: 'es', | ||
|
||
// Separate modules, not bundled | ||
preserveModules: true | ||
}, | ||
|
||
/** | ||
* ECMAScript (ES) module bundles for browser <script type="module"> | ||
* or using `import` for modern browsers and Node.js scripts | ||
*/ | ||
{ | ||
format: 'es', | ||
|
||
// Bundled modules | ||
preserveModules: false | ||
}, | ||
|
||
/** | ||
* Universal Module Definition (UMD) bundle for browser <script> | ||
* `window` globals and compatibility with CommonJS and AMD `require()` | ||
*/ | ||
{ | ||
format: 'umd', | ||
|
||
// Bundled modules | ||
preserveModules: false, | ||
|
||
// Components are given names (e.g window.GOVUKFrontend.Accordion) | ||
amd: { id: componentPathToModuleName(input) }, | ||
name: componentPathToModuleName(input) | ||
} | ||
], | ||
|
||
/** | ||
* Input plugins | ||
*/ | ||
plugins: [ | ||
replace({ | ||
include: '**/common/govuk-frontend-version.mjs', | ||
preventAssignment: true, | ||
|
||
// Add GOV.UK Frontend release version | ||
development: pkg.version | ||
}) | ||
] | ||
})) |
Oops, something went wrong.