From 625498198052a9bb84c633fe17d4124d28ce704d Mon Sep 17 00:00:00 2001 From: Jonas Schell Date: Fri, 21 Apr 2023 11:19:55 +0200 Subject: [PATCH] turn on source maps for production (#59) * turn on source maps * add source-map-loader --- next.config.js | 15 ++++++++++++++- package.json | 3 ++- tsconfig.json | 3 ++- yarn.lock | 26 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/next.config.js b/next.config.js index 56239b8..29f4c9c 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,20 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: false, - swcMinify: true, + swcMinify: false, + productionBrowserSourceMaps: true, + webpack: (config, { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }) => { + // Important: return the modified config + config.module.rules = [ + ...config.module.rules, + { + test: /\.mjs$/, + enforce: 'pre', + use: ['source-map-loader'], + }, + ]; + return config; + }, }; module.exports = nextConfig; diff --git a/package.json b/package.json index 77edd81..ef6ccd7 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@types/react-dom": "18.0.11", "eslint": "8.37.0", "eslint-config-next": "12.3.4", + "source-map-loader": "^4.0.1", "typescript": "4.9.5" } -} +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 99710e8..b76265e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,8 @@ "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", - "incremental": true + "incremental": true, + "sourceMap": true }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] diff --git a/yarn.lock b/yarn.lock index f77485f..079ebb5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -372,6 +372,11 @@ "@typescript-eslint/types" "5.33.0" eslint-visitor-keys "^3.3.0" +abab@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" + integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA== + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -1257,6 +1262,13 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +iconv-lite@^0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + ignore@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" @@ -2085,6 +2097,11 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" +"safer-buffer@>= 2.1.2 < 3.0.0": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + scheduler@^0.23.0: version "0.23.0" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.0.tgz#ba8041afc3d30eb206a487b6b384002e4e61fdfe" @@ -2150,6 +2167,15 @@ source-map-js@^1.0.2: resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== +source-map-loader@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-4.0.1.tgz#72f00d05f5d1f90f80974eda781cbd7107c125f2" + integrity sha512-oqXpzDIByKONVY8g1NUPOTQhe0UTU5bWUl32GSkqK2LjJj0HmwTMVKxcUip0RgAYhY1mqgOxjbQM48a0mmeNfA== + dependencies: + abab "^2.0.6" + iconv-lite "^0.6.3" + source-map-js "^1.0.2" + string.prototype.matchall@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz#3bf85722021816dcd1bf38bb714915887ca79fd3"