Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ module.exports = {
},
},
{
files: ['scripts/**/*.mjs', 'packages/**/*.mjs'],
files: ['**/*.mjs'],
rules: {
'import/extensions': ['error', 'ignorePackages'],
},
Expand Down
27 changes: 17 additions & 10 deletions docs/next.config.js → docs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
// @ts-check
const path = require('path');
// @ts-ignore
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const pkg = require('../package.json');
const withDocsInfra = require('./nextConfigDocsInfra');
const { findPages } = require('./src/modules/utils/find');
const {
import * as path from 'path';
import * as url from 'url';
import * as fs from 'fs';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import { createRequire } from 'module';
import withDocsInfra from './nextConfigDocsInfra.js';
import { findPages } from './src/modules/utils/find.mjs';
Comment on lines +8 to +9
Copy link
Member

@oliviertassinari oliviertassinari Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about this. Why add the extensions?

Edit: oh lol really? https://nodejs.org/api/esm.html#mandatory-file-extensions

Mandatory file extensions

Copy link
Member Author

@Janpot Janpot Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.js follows the native browser implementation in its resolver for esm, full paths mandatory. I guess it guarantees predictable amount of io access during module loading? It's more important on the web.
I think I saw somewhere that they're porting the classic node resolver to esm, but it's still experimental.

import {
LANGUAGES,
LANGUAGES_SSR,
LANGUAGES_IGNORE_PAGES,
LANGUAGES_IN_PROGRESS,
} = require('./config');
} from './config.js';

const workspaceRoot = path.join(__dirname, '../');
const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
const require = createRequire(import.meta.url);

const workspaceRoot = path.join(currentDirectory, '../');

const l10nPRInNetlify = /^l10n_/.test(process.env.HEAD || '') && process.env.NETLIFY === 'true';
const vercelDeploy = Boolean(process.env.VERCEL);
const isDeployPreview = Boolean(process.env.PULL_REQUEST_ID);
// For crowdin PRs we want to build all locales for testing.
const buildOnlyEnglishLocale = isDeployPreview && !l10nPRInNetlify && !vercelDeploy;

module.exports = withDocsInfra({
const pkgContent = fs.readFileSync(path.resolve(workspaceRoot, 'package.json'), 'utf8');
const pkg = JSON.parse(pkgContent);

export default withDocsInfra({
webpack: (config, options) => {
const plugins = config.plugins.slice();

Expand Down
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"@types/react-transition-group": "^4.4.10",
"@types/react-window": "^1.8.8",
"@types/stylis": "^4.2.0",
"@types/webpack-bundle-analyzer": "^4.6.3",
"chai": "^4.4.1",
"cross-fetch": "^4.0.0",
"gm": "^1.25.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const fs = require('fs');
const path = require('path');
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 pageRegex = /(\.js|\.tsx)$/;
const blackList = ['/.eslintrc', '/_document', '/_app'];
Expand All @@ -19,9 +22,10 @@ const blackList = ['/.eslintrc', '/_document', '/_app'];
* @param {NextJSPage[]} pages
* @returns {NextJSPage[]}
*/
function findPages(
// eslint-disable-next-line import/prefer-default-export
export function findPages(
options = {},
directory = path.resolve(__dirname, '../../../pages'),
directory = path.resolve(currentDirectory, '../../../pages'),
pages = [],
) {
fs.readdirSync(directory).forEach((item) => {
Expand Down Expand Up @@ -80,7 +84,3 @@ function findPages(

return pages;
}

module.exports = {
findPages,
};
2 changes: 1 addition & 1 deletion docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.json",
"include": ["next-env.d.ts", "types", "src", "pages", "data", "next.config.js"],
"include": ["next-env.d.ts", "types", "src", "pages", "data", "next.config.mjs"],
"compilerOptions": {
"allowJs": true,
"isolatedModules": true,
Expand Down
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

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