Files
next.js/packages/next/next-devtools.webpack-config.js
Arian Tron 61f56f997c
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
first commit
2026-03-10 19:37:31 +03:30

146 lines
4.5 KiB
JavaScript

const path = require('path')
const webpack = require('@rspack/core')
const MODERN_BROWSERSLIST_TARGET = require('./src/shared/lib/modern-browserslist-target')
const DevToolsIgnoreListPlugin = require('./webpack-plugins/devtools-ignore-list-plugin')
function shouldIgnorePath(modulePath) {
// For consumers, everything will be considered 3rd party dependency if they use
// the bundles we produce here.
// In other words, this is all library code and should therefore be ignored.
return true
}
/**
* @param {Object} options
* @param {boolean} options.dev
* @param {Partial<webpack.Configuration>} options.rest
* @returns {webpack.Configuration}
*/
module.exports = ({ dev, ...rest }) => {
const experimental = false
const bundledReactChannel = experimental ? '-experimental' : ''
const target = `browserslist:${MODERN_BROWSERSLIST_TARGET.join(', ')}`
return {
entry: path.join(__dirname, 'src/next-devtools/entrypoint.ts'),
target,
mode: dev ? 'development' : 'production',
output: {
path: path.join(__dirname, 'dist/compiled/next-devtools'),
filename: `index.js`,
iife: false,
library: {
type: 'commonjs-static',
},
},
devtool: 'source-map',
optimization: {
moduleIds: 'named',
minimize: true,
concatenateModules: true,
minimizer: [
new webpack.SwcJsMinimizerRspackPlugin({
minimizerOptions: {
mangle: dev || process.env.NEXT_SERVER_NO_MANGLE ? false : true,
},
}),
],
},
plugins: [
// TODO: React Compiler
new DevToolsIgnoreListPlugin({ shouldIgnorePath }),
].filter(Boolean),
stats: {
optimizationBailout: true,
},
resolve: {
alias: {
// TODO: Get dedicated React version for NDT to uncouple development.
react: `next/dist/compiled/react${bundledReactChannel}`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}`,
'react-dom/client$': `next/dist/compiled/react-dom${bundledReactChannel}/client`,
'react-is$': `next/dist/compiled/react-is${bundledReactChannel}`,
scheduler$: `next/dist/compiled/scheduler${bundledReactChannel}`,
},
extensions: ['.ts', '.tsx', '.js', '.json'],
},
module: {
rules: [
{ test: /\.m?js$/, loader: `source-map-loader`, enforce: `pre` },
{
test: /\.(ts|tsx)$/,
exclude: [/node_modules/],
loader: 'builtin:swc-loader',
/** @type {import('@rspack/core').SwcLoaderOptions} */
options: {
env: {
targets: MODERN_BROWSERSLIST_TARGET,
},
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
development: dev,
runtime: 'automatic',
// TODO: Fast Refresh
// refresh: dev,
},
},
},
},
type: 'javascript/auto',
},
{
test: /\.(ts|tsx)$/,
exclude: [/node_modules/],
loader: 'babel-loader',
options: {
plugins: [
[
'babel-plugin-react-compiler',
/**
* @type {import('babel-plugin-react-compiler').PluginOptions}
*/
({
environment: {
enableNameAnonymousFunctions: dev,
},
}),
],
['@babel/plugin-syntax-typescript', { isTSX: true }],
],
sourceMaps: true,
},
type: 'javascript/auto',
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: {
// Explicitly set the injectType to 'styleTag' which is also the default behavior.
// We've experienced `singletonStyleTag` that the later updated styles not being applied.
// Keep using `styleTag` to ensure when new styles injected the style can also be updated.
injectType: 'styleTag',
insert: require.resolve(
'./src/build/webpack/loaders/devtool/devtool-style-inject.js'
),
},
},
{ loader: 'css-loader', options: { sourceMap: false } },
],
},
],
},
externals: [],
experiments: {},
...rest,
}
}