From 3d2b676cd8cb7f1e2552b2e1f4c5ea6d38a15e17 Mon Sep 17 00:00:00 2001 From: MUI bot <2109932+Janpot@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:54:15 +0100 Subject: [PATCH] Revert next.conifg.mjs changes --- docs/{next.config.mjs => next.config.js} | 22 +++++++------------- docs/src/modules/utils/{find.mjs => find.js} | 13 ++++++------ docs/tsconfig.json | 2 +- 3 files changed, 15 insertions(+), 22 deletions(-) rename docs/{next.config.mjs => next.config.js} (94%) rename docs/src/modules/utils/{find.mjs => find.js} (88%) diff --git a/docs/next.config.mjs b/docs/next.config.js similarity index 94% rename from docs/next.config.mjs rename to docs/next.config.js index 14def7cc34e9a0..dc6cbbfabeeff7 100644 --- a/docs/next.config.mjs +++ b/docs/next.config.js @@ -1,24 +1,18 @@ // @ts-check -import * as path from 'path'; -import * as url from 'url'; -import * as fs from 'fs'; +const path = require('path'); +const fs = require('fs'); // @ts-ignore -import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; -import { createRequire } from 'module'; -import { findPages } from './src/modules/utils/find.mjs'; - -const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url)); -const require = createRequire(import.meta.url); - -const withDocsInfra = require('./nextConfigDocsInfra.js'); +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); +const { findPages } = require('./src/modules/utils/find'); +const withDocsInfra = require('./nextConfigDocsInfra'); const { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES, LANGUAGES_IN_PROGRESS, -} = require('./config.js'); +} = require('./config'); -const workspaceRoot = path.join(currentDirectory, '../'); +const workspaceRoot = path.join(__dirname, '../'); const l10nPRInNetlify = /^l10n_/.test(process.env.HEAD || '') && process.env.NETLIFY === 'true'; const vercelDeploy = Boolean(process.env.VERCEL); @@ -29,7 +23,7 @@ const buildOnlyEnglishLocale = isDeployPreview && !l10nPRInNetlify && !vercelDep const pkgContent = fs.readFileSync(path.resolve(workspaceRoot, 'package.json'), 'utf8'); const pkg = JSON.parse(pkgContent); -export default withDocsInfra({ +module.exports = withDocsInfra({ webpack: (config, options) => { const plugins = config.plugins.slice(); diff --git a/docs/src/modules/utils/find.mjs b/docs/src/modules/utils/find.js similarity index 88% rename from docs/src/modules/utils/find.mjs rename to docs/src/modules/utils/find.js index cffc301583f296..c82ffeac520a0d 100644 --- a/docs/src/modules/utils/find.mjs +++ b/docs/src/modules/utils/find.js @@ -1,8 +1,5 @@ -import * as fs from 'fs'; -import * as url from 'url'; -import * as path from 'path'; - -const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url)); +const fs = require('fs'); +const path = require('path'); const pageRegex = /(\.js|\.tsx)$/; const blackList = ['/.eslintrc', '/_document', '/_app']; @@ -23,9 +20,9 @@ const blackList = ['/.eslintrc', '/_document', '/_app']; * @returns {NextJSPage[]} */ // eslint-disable-next-line import/prefer-default-export -export function findPages( +function findPages( options = {}, - directory = path.resolve(currentDirectory, '../../../pages'), + directory = path.resolve(__dirname, '../../../pages'), pages = [], ) { fs.readdirSync(directory).forEach((item) => { @@ -84,3 +81,5 @@ export function findPages( return pages; } + +module.exports.findPages = findPages; diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 1303011574a0c7..4dc232509b9b8b 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "../tsconfig.json", - "include": ["next-env.d.ts", "types", "src", "pages", "data", "next.config.mjs"], + "include": ["next-env.d.ts", "types", "src", "pages", "data", "next.config.js"], "compilerOptions": { "allowJs": true, "isolatedModules": true,