Created
November 11, 2021 12:17
-
-
Save salembaira/bd17433ff7bb0ad27122db8ffb896e81 to your computer and use it in GitHub Desktop.
next.js patch to enable decorators and remove console.log in production build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/node_modules/next/dist/build/webpack-config.js b/node_modules/next/dist/build/webpack-config.js | |
| index 5fe4dd5..a13e97a 100644 | |
| --- a/node_modules/next/dist/build/webpack-config.js | |
| +++ b/node_modules/next/dist/build/webpack-config.js | |
| @@ -736,7 +736,7 @@ async function getBaseWebpackConfig(dir, { buildId , config , dev =false , isSer | |
| )) { | |
| return false; | |
| } | |
| - return /node_modules/.test(excludePath); | |
| + return /node_modules|tableau-react/.test(excludePath); | |
| } | |
| }; | |
| let webpackConfig = { | |
| diff --git a/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js b/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js | |
| index bc89009..4efb5ff 100644 | |
| --- a/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js | |
| +++ b/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js | |
| @@ -13,10 +13,14 @@ function getSWCOptions({ filename , isServer , development , isPageFile , pagesD | |
| parser: { | |
| syntax: isTypeScript ? 'typescript' : 'ecmascript', | |
| dynamicImport: true, | |
| + decorators: true, | |
| // Exclude regular TypeScript files from React transformation to prevent e.g. generic parameters and angle-bracket type assertion from being interpreted as JSX tags. | |
| [isTypeScript ? 'tsx' : 'jsx']: isTSFile ? false : true | |
| }, | |
| + externalHelpers: true, | |
| + loose: true, | |
| transform: { | |
| + legacyDecorator: true, | |
| react: { | |
| runtime: 'automatic', | |
| pragma: 'React.createElement', | |
| diff --git a/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js b/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js | |
| index b16e7a4..b8d5a65 100644 | |
| --- a/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js | |
| +++ b/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js | |
| @@ -140,7 +140,9 @@ class TerserPlugin { | |
| } | |
| } : { | |
| }, | |
| - compress: true, | |
| + compress: { | |
| + drop_console: true | |
| + }, | |
| mangle: true | |
| }); | |
| return result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment