diff --git a/app/nodemon.json b/app/nodemon.json index 897d4f4059..64f22679e9 100644 --- a/app/nodemon.json +++ b/app/nodemon.json @@ -1,6 +1,6 @@ { "watch": ["./src", "../package/src/govuk/**/*.{json,yaml}"], - "ignore": ["**/*.test.*"], + "ignore": ["./src/javascripts/**", "**/*.test.*"], "ext": "mjs,json,yaml", "quiet": true } diff --git a/app/package.json b/app/package.json index 51122d334d..ecb2800b7c 100644 --- a/app/package.json +++ b/app/package.json @@ -22,6 +22,7 @@ "govuk_frontend_toolkit": "^9.0.1", "govuk_template_jinja": "^0.26.0", "govuk-elements-sass": "3.1.3", + "govuk-frontend": "*", "govuk-frontend-config": "*", "govuk-frontend-lib": "*", "highlight.js": "^11.7.0", diff --git a/app/src/javascripts/all.mjs b/app/src/javascripts/all.mjs new file mode 100644 index 0000000000..7ac35e4fdd --- /dev/null +++ b/app/src/javascripts/all.mjs @@ -0,0 +1,4 @@ +import * as GOVUKFrontend from 'govuk-frontend' + +// Manually window global for tests +window.GOVUKFrontend = GOVUKFrontend diff --git a/app/src/stylesheets/app-ie8.scss b/app/src/stylesheets/app-ie8.scss index b58b049a27..cd0449d64c 100644 --- a/app/src/stylesheets/app-ie8.scss +++ b/app/src/stylesheets/app-ie8.scss @@ -1,3 +1,3 @@ -@import "../../../package/src/govuk/all-ie8"; +@import "govuk/all-ie8"; @import "partials/app"; @import "partials/banner"; diff --git a/app/src/stylesheets/app.scss b/app/src/stylesheets/app.scss index 1203c6b050..e8c8d4222e 100644 --- a/app/src/stylesheets/app.scss +++ b/app/src/stylesheets/app.scss @@ -1,7 +1,7 @@ $govuk-show-breakpoints: true; $govuk-new-link-styles: true; -@import "../../../package/src/govuk/all"; +@import "govuk/all"; @import "partials/app"; @import "partials/code"; @import "partials/banner"; diff --git a/app/src/stylesheets/full-page-examples/campaign-page.scss b/app/src/stylesheets/full-page-examples/campaign-page.scss index 79c69cdaf1..9be877bba7 100644 --- a/app/src/stylesheets/full-page-examples/campaign-page.scss +++ b/app/src/stylesheets/full-page-examples/campaign-page.scss @@ -1,6 +1,6 @@ -@import "../../../../package/src/govuk/base"; +@import "govuk/base"; $govuk-new-link-styles: true; -@import "../../../../package/src/govuk/core/all"; +@import "govuk/core/all"; .app-header--campaign { padding-bottom: govuk-spacing(2); diff --git a/app/src/stylesheets/full-page-examples/search.scss b/app/src/stylesheets/full-page-examples/search.scss index 8758f018b2..e5d4f03944 100644 --- a/app/src/stylesheets/full-page-examples/search.scss +++ b/app/src/stylesheets/full-page-examples/search.scss @@ -1,6 +1,6 @@ -@import "../../../../package/src/govuk/base"; +@import "govuk/base"; $govuk-new-link-styles: true; -@import "../../../../package/src/govuk/core/all"; +@import "govuk/core/all"; .app-document-list > li { padding-top: govuk-spacing(4); diff --git a/app/tasks/scripts.mjs b/app/tasks/scripts.mjs index 89119ab7f6..65ba80fdf7 100644 --- a/app/tasks/scripts.mjs +++ b/app/tasks/scripts.mjs @@ -11,7 +11,7 @@ import gulp from 'gulp' export const compile = gulp.series( task.name('compile:js', () => scripts.compile('all.mjs', { - srcPath: join(paths.src, 'govuk'), + srcPath: join(paths.app, 'src/javascripts'), destPath: join(paths.app, 'dist/javascripts'), filePath (file) { diff --git a/app/tasks/watch.mjs b/app/tasks/watch.mjs index 3ab0419f1f..f49f221dea 100644 --- a/app/tasks/watch.mjs +++ b/app/tasks/watch.mjs @@ -27,6 +27,7 @@ export function watch () { gulp.watch([ `${slash(paths.root)}/jsdoc.config.js`, + `${slash(paths.app)}/src/javascripts/**/*.mjs`, `${slash(paths.src)}/govuk/**/*.mjs` ], gulp.parallel( npm.script('lint:js'), diff --git a/docs/examples/webpack/src/assets/stylesheets/app.scss b/docs/examples/webpack/src/assets/stylesheets/app.scss index 0c80542e0b..d05b181b37 100644 --- a/docs/examples/webpack/src/assets/stylesheets/app.scss +++ b/docs/examples/webpack/src/assets/stylesheets/app.scss @@ -1 +1 @@ -@import "govuk-frontend/govuk/all"; +@import "govuk/all"; diff --git a/docs/examples/webpack/webpack.config.js b/docs/examples/webpack/webpack.config.js index f3ef876861..0224b41937 100644 --- a/docs/examples/webpack/webpack.config.js +++ b/docs/examples/webpack/webpack.config.js @@ -1,10 +1,10 @@ -const { dirname, join } = require('path') +const { dirname, join, resolve } = require('path') const CopyPlugin = require('copy-webpack-plugin') const TerserPlugin = require('terser-webpack-plugin') // Module resolution -const frontendPath = dirname(require.resolve('govuk-frontend')) +const frontendPath = resolve(dirname(require.resolve('govuk-frontend')), '../') // Build paths const srcPath = join(__dirname, 'src') @@ -58,6 +58,7 @@ module.exports = ({ WEBPACK_SERVE }, { mode }) => ({ loader: 'sass-loader', options: { sassOptions: { + includePaths: [frontendPath], quietDeps: true } } @@ -94,7 +95,7 @@ module.exports = ({ WEBPACK_SERVE }, { mode }) => ({ patterns: [ join(srcPath, 'index.html'), { - context: join(frontendPath, 'assets'), + context: join(frontendPath, './govuk/assets'), from: '{fonts,images}/**', to: 'assets' } diff --git a/package-lock.json b/package-lock.json index 912fa178af..3be7e591c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -93,6 +93,7 @@ "govuk_frontend_toolkit": "^9.0.1", "govuk_template_jinja": "^0.26.0", "govuk-elements-sass": "3.1.3", + "govuk-frontend": "*", "govuk-frontend-config": "*", "govuk-frontend-lib": "*", "highlight.js": "^11.7.0", @@ -4571,6 +4572,15 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", "devOptional": true }, + "node_modules/@types/resolve": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", + "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/responselike": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", @@ -6694,6 +6704,18 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/builtins": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz", @@ -13695,6 +13717,12 @@ "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==", "dev": true }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, "node_modules/is-negated-glob": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", @@ -22070,6 +22098,19 @@ "rollup": "bin/rollup" } }, + "node_modules/rollup-plugin-node-resolve": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-4.2.4.tgz", + "integrity": "sha512-t/64I6l7fZ9BxqD3XlX4ZeO6+5RLKyfpwE2CiPNUKa+GocPlQhf/C208ou8y3AwtNsc6bjSk/8/6y/YAyxCIvw==", + "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-node-resolve.", + "dev": true, + "dependencies": { + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.10.0" + } + }, "node_modules/rollup-plugin-replace": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz", @@ -26841,10 +26882,23 @@ }, "package": { "name": "govuk-frontend", - "version": "4.5.0", "license": "MIT", + "devDependencies": { + "cheerio": "^1.0.0-rc.12", + "govuk-frontend-config": "*", + "govuk-frontend-helpers": "*", + "govuk-frontend-lib": "*", + "html-validate": "7.15.1", + "nunjucks": "^3.2.3", + "outdent": "^0.8.0", + "puppeteer": "^19.9.0", + "sass-embedded": "^1.60.0", + "sassdoc": "^2.7.4", + "slash": "^5.0.0" + }, "engines": { - "node": ">= 4.2.0" + "node": "^18.12.0", + "npm": "^8.1.0 || ^9.1.0" } }, "package/dist": { @@ -26927,6 +26981,7 @@ "postcss-load-config": "^4.0.1", "puppeteer": "^19.9.0", "rollup": "0.59.4", + "rollup-plugin-node-resolve": "^4.2.4", "rollup-plugin-replace": "^2.2.0", "sass-embedded": "^1.60.0", "slash": "^5.0.0", diff --git a/package/src/govuk/components/globals.test.mjs b/package/src/govuk/components/globals.test.mjs index b6e2f44fc4..81c36a860b 100644 --- a/package/src/govuk/components/globals.test.mjs +++ b/package/src/govuk/components/globals.test.mjs @@ -31,14 +31,15 @@ describe('GOV.UK Frontend', () => { it('exports Components', async () => { const components = exported .filter(method => !['initAll', 'version'].includes(method)) + .sort() // Ensure GOV.UK Frontend exports the expected components expect(components).toEqual([ 'Accordion', 'Button', - 'Details', 'CharacterCount', 'Checkboxes', + 'Details', 'ErrorSummary', 'Header', 'NotificationBanner', diff --git a/shared/tasks/package.json b/shared/tasks/package.json index 4818192f78..8b70d4f2e7 100644 --- a/shared/tasks/package.json +++ b/shared/tasks/package.json @@ -28,6 +28,7 @@ "postcss-load-config": "^4.0.1", "puppeteer": "^19.9.0", "rollup": "0.59.4", + "rollup-plugin-node-resolve": "^4.2.4", "rollup-plugin-replace": "^2.2.0", "sass-embedded": "^1.60.0", "slash": "^5.0.0", diff --git a/shared/tasks/scripts.mjs b/shared/tasks/scripts.mjs index 24e0ca79c4..d7a7fcdd3e 100644 --- a/shared/tasks/scripts.mjs +++ b/shared/tasks/scripts.mjs @@ -5,6 +5,7 @@ import { getListing } from 'govuk-frontend-lib/files' import { componentPathToModuleName } from 'govuk-frontend-lib/names' import PluginError from 'plugin-error' import { rollup } from 'rollup' +import resolve from 'rollup-plugin-node-resolve' import replace from 'rollup-plugin-replace' import { minify } from 'terser' @@ -41,7 +42,8 @@ export async function compileJavaScript ([modulePath, { srcPath, destPath, fileP const moduleDestPath = join(destPath, filePath ? filePath(parse(modulePath)) : modulePath) // Rollup plugins - const plugins = [] + // @ts-expect-error "This expression is not callable" due to incorrect types + const plugins = [resolve()] if (!isDev) { // Add GOV.UK Frontend release version diff --git a/shared/tasks/styles.mjs b/shared/tasks/styles.mjs index 3a9d917ef3..e604b23d3a 100644 --- a/shared/tasks/styles.mjs +++ b/shared/tasks/styles.mjs @@ -64,6 +64,7 @@ export async function compileStylesheet ([modulePath, { srcPath, destPath, fileP // Resolve @imports via loadPaths: [ join(paths.root, 'node_modules/govuk_frontend_toolkit/stylesheets'), + join(paths.root, 'node_modules/govuk-frontend/src'), join(paths.root, 'node_modules') ],