Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions docusaurus.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
const path = require('path');
const path = require('node:path');
const { getBabelOptions } = require('@docusaurus/babel');
require('dotenv').config({ path: path.join(__dirname, '.env'), quiet: true });

/** @type {import('@docusaurus/types').Config} */
Expand Down Expand Up @@ -31,8 +32,29 @@ const config = {

presets: [],

// Docusaurus compiles the map's source with loose Babel, which assumes every iterable
// is an array: [...map.values()] becomes [].concat(map.values()), an array holding the
// iterator rather than its values. Turning off that one assumption spreads iterables
// properly and keeps the rest of the Docusaurus Babel setup.
//
// It's limited to the map's own source because Docusaurus also compiles its own
// CommonJS packages, where the helper imports this adds break their `exports`.
webpack: {
jsLoader: (isServer) => ({
loader: require.resolve('babel-loader'),
options: {
...getBabelOptions({ isServer }),
overrides: [{
include: ['src', 'plugins', 'providers'].map((dir) => path.join(__dirname, dir)),
assumptions: { iterableIsArray: false },
}],
},
}),
},

themes: [
[
/** @type {import('@docusaurus/types').PluginConfig} */
([
require.resolve('@easyops-cn/docusaurus-search-local'),
/** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */
({
Expand All @@ -45,7 +67,7 @@ const config = {
highlightSearchTermsOnTargetPage: true,
searchResultContextMaxLength: 60,
}),
],
]),
'@defra/docusaurus-theme-govuk',
],

Expand Down
1 change: 1 addition & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"@babel/preset-env": "^7.28.0",
"@babel/preset-react": "^7.27.1",
"@defra/docusaurus-theme-govuk": "^0.0.22-alpha",
"@docusaurus/babel": "^3.10.1",
"@docusaurus/core": "^3.10.1",
"@docusaurus/module-type-aliases": "^3.10.1",
"@docusaurus/plugin-content-docs": "^3.10.1",
Expand Down
Loading