From 22734b7d9085492574c212832f2ff91cdb8fb1a2 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 23 May 2022 19:24:30 +0100 Subject: [PATCH] [Beta] Do not bundle built-in ESLint rules --- beta/next.config.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/beta/next.config.js b/beta/next.config.js index 7b3222720c4..5ee8a4da0b7 100644 --- a/beta/next.config.js +++ b/beta/next.config.js @@ -38,6 +38,24 @@ module.exports = { ); } + const {IgnorePlugin} = require('webpack'); + config.plugins.push( + new IgnorePlugin({ + checkResource(resource, context) { + if ( + /\/eslint\/lib\/rules$/.test(context) && + /\.\/[\w-]+(\.js)?$/.test(resource) + ) { + // Skips imports of built-in rules that ESLint + // tries to carry into the bundle by default. + // We only want the engine and the React rules. + return true; + } + return false; + }, + }) + ); + // Add our custom markdown loader in order to support frontmatter // and layout config.module.rules.push({