Unverified Commit 511cf748 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Enable "paths" support by default (#11970)

* Enable "paths" support by default

* Enable NEXT_PUBLIC_ prefix exposing the variable globally

Part of #11106
parent 26df0180
...@@ -768,8 +768,7 @@ export default async function getBaseWebpackConfig( ...@@ -768,8 +768,7 @@ export default async function getBaseWebpackConfig(
// This plugin makes sure `output.filename` is used for entry chunks // This plugin makes sure `output.filename` is used for entry chunks
new ChunkNamesPlugin(), new ChunkNamesPlugin(),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
...(config.experimental.pageEnv ...Object.keys(process.env).reduce(
? Object.keys(process.env).reduce(
(prev: { [key: string]: string }, key: string) => { (prev: { [key: string]: string }, key: string) => {
if (key.startsWith('NEXT_PUBLIC_')) { if (key.startsWith('NEXT_PUBLIC_')) {
prev[`process.env.${key}`] = JSON.stringify(process.env[key]!) prev[`process.env.${key}`] = JSON.stringify(process.env[key]!)
...@@ -777,8 +776,7 @@ export default async function getBaseWebpackConfig( ...@@ -777,8 +776,7 @@ export default async function getBaseWebpackConfig(
return prev return prev
}, },
{} {}
) ),
: {}),
...Object.keys(config.env).reduce((acc, key) => { ...Object.keys(config.env).reduce((acc, key) => {
if (/^(?:NODE_.+)|^(?:__.+)$/i.test(key)) { if (/^(?:NODE_.+)|^(?:__.+)$/i.test(key)) {
throw new Error( throw new Error(
...@@ -1005,11 +1003,7 @@ export default async function getBaseWebpackConfig( ...@@ -1005,11 +1003,7 @@ export default async function getBaseWebpackConfig(
webpackConfig.resolve?.modules?.push(resolvedBaseUrl) webpackConfig.resolve?.modules?.push(resolvedBaseUrl)
} }
if ( if (jsConfig?.compilerOptions?.paths && resolvedBaseUrl) {
config.experimental.jsconfigPaths &&
jsConfig?.compilerOptions?.paths &&
resolvedBaseUrl
) {
webpackConfig.resolve?.plugins?.push( webpackConfig.resolve?.plugins?.push(
new JsConfigPathsPlugin(jsConfig.compilerOptions.paths, resolvedBaseUrl) new JsConfigPathsPlugin(jsConfig.compilerOptions.paths, resolvedBaseUrl)
) )
......
...@@ -41,7 +41,6 @@ const defaultConfig: { [key: string]: any } = { ...@@ -41,7 +41,6 @@ const defaultConfig: { [key: string]: any } = {
(Number(process.env.CIRCLE_NODE_TOTAL) || (Number(process.env.CIRCLE_NODE_TOTAL) ||
(os.cpus() || { length: 1 }).length) - 1 (os.cpus() || { length: 1 }).length) - 1
), ),
jsconfigPaths: false,
css: true, css: true,
scss: true, scss: true,
documentMiddleware: false, documentMiddleware: false,
......
module.exports = { module.exports = {
experimental: { experimental: {
pageEnv: true,
async redirects() { async redirects() {
return [ return [
{ {
......
module.exports = { module.exports = {
experimental: {
jsconfigPaths: true,
},
onDemandEntries: { onDemandEntries: {
// Make sure entries are not getting disposed. // Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60, maxInactiveAge: 1000 * 60 * 60,
......
module.exports = { module.exports = {
experimental: {
jsconfigPaths: true,
},
onDemandEntries: { onDemandEntries: {
// Make sure entries are not getting disposed. // Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60, maxInactiveAge: 1000 * 60 * 60,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment