Skip to content

Commit f9e2c13

Browse files
authored
Remove 'esquery' hack to potentially enable Turbopack (#8115)
* Remove esquery hack * Add comment explaining next.config change
1 parent e57e912 commit f9e2c13

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

next.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ const nextConfig = {
3636
// Don't bundle the shim unnecessarily.
3737
config.resolve.alias['use-sync-external-store/shim'] = 'react';
3838

39+
// ESLint depends on the CommonJS version of esquery,
40+
// but Webpack loads the ESM version by default. This
41+
// alias ensures the correct version is used.
42+
//
43+
// More info:
44+
// https://github.com/reactjs/react.dev/pull/8115
45+
config.resolve.alias['esquery'] = 'esquery/dist/esquery.min.js';
46+
3947
const {IgnorePlugin, NormalModuleReplacementPlugin} = require('webpack');
4048
config.plugins.push(
4149
new NormalModuleReplacementPlugin(

src/components/MDX/Sandpack/runESLint.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ const getCodeMirrorPosition = (
2121

2222
const linter = new Linter();
2323

24-
// HACK! Eslint requires 'esquery' using `require`, but there's no commonjs interop.
25-
// because of this it tries to run `esquery.parse()`, while there's only `esquery.default.parse()`.
26-
// This hack places the functions in the right place.
27-
const esquery = require('esquery');
28-
esquery.parse = esquery.default?.parse;
29-
esquery.matches = esquery.default?.matches;
30-
3124
const reactRules = require('eslint-plugin-react-hooks').rules;
3225
linter.defineRules({
3326
'react-hooks/rules-of-hooks': reactRules['rules-of-hooks'],

0 commit comments

Comments
 (0)