From 35bf47a3c24cab4a18688c3e7422f4caf7b6cfb6 Mon Sep 17 00:00:00 2001 From: Martynas Date: Fri, 8 Nov 2024 18:16:02 +0200 Subject: [PATCH] build: fix packages/* and service worker source maps (#1523) --- apps/browser-extension-wallet/package.json | 1 + apps/browser-extension-wallet/webpack.common.js | 5 +++++ apps/browser-extension-wallet/webpack.sw.prod.js | 10 +++++++++- packages/nami/rollup.config.js | 2 ++ packages/staking/tsup.config.ts | 2 +- rollup.config.js | 2 ++ yarn.lock | 13 +++++++++++++ 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/apps/browser-extension-wallet/package.json b/apps/browser-extension-wallet/package.json index 64eca7e15c..401a0bc79f 100644 --- a/apps/browser-extension-wallet/package.json +++ b/apps/browser-extension-wallet/package.json @@ -117,6 +117,7 @@ "fake-indexeddb": "3.1.3", "fork-ts-checker-webpack-plugin": "^7.2.1", "jest-webextension-mock": "^3.9.0", + "source-map-loader": "^5.0.0", "text-encoding-utf-8": "^1.0.2", "tsconfig-paths-webpack-plugin": "3.5.2", "webassembly-loader-sw": "^1.1.0" diff --git a/apps/browser-extension-wallet/webpack.common.js b/apps/browser-extension-wallet/webpack.common.js index 2d9967f91e..2d204a3f7f 100644 --- a/apps/browser-extension-wallet/webpack.common.js +++ b/apps/browser-extension-wallet/webpack.common.js @@ -30,6 +30,11 @@ module.exports = () => { }, module: { rules: [ + { + test: /packages\/.+\/dist\/.+\.js$/, + enforce: 'pre', + use: ['source-map-loader'] + }, { test: /\.(js|jsx|ts|tsx)$/, exclude: /node_modules\/(?!(@cardano-sdk)\/).*/, diff --git a/apps/browser-extension-wallet/webpack.sw.prod.js b/apps/browser-extension-wallet/webpack.sw.prod.js index 2b0a4d8423..a404faeb79 100644 --- a/apps/browser-extension-wallet/webpack.sw.prod.js +++ b/apps/browser-extension-wallet/webpack.sw.prod.js @@ -15,5 +15,13 @@ module.exports = () => // Needed for the service worker to work with a production build // TODO: after removing imports from dist/cjs, service worker no longer loads when built in production mode. // It is likely that some optimization is triggering it, such as tree shaking. - { mode: 'development', optimization: { moduleIds: 'named', mangleExports: false } } + { + mode: 'development', + optimization: { + moduleIds: 'named', + mangleExports: false, + // minimize mess up the source maps + minimize: false + } + } ); diff --git a/packages/nami/rollup.config.js b/packages/nami/rollup.config.js index c6b8ffa6a3..03afcac0ab 100644 --- a/packages/nami/rollup.config.js +++ b/packages/nami/rollup.config.js @@ -13,6 +13,8 @@ const common = { typescript({ tsconfig: './src/tsconfig.json', composite: false, + sourceMap: true, + inlineSources: true, }), json(), commonjs(), diff --git a/packages/staking/tsup.config.ts b/packages/staking/tsup.config.ts index d5454725d5..3375357de9 100644 --- a/packages/staking/tsup.config.ts +++ b/packages/staking/tsup.config.ts @@ -26,7 +26,7 @@ const tsupConfig = defineConfig([ }, name: 'lace/staking', outDir: './dist', - sourcemap: false, + sourcemap: true, }, ]); diff --git a/rollup.config.js b/rollup.config.js index 2e6580dfb0..d6fb8da138 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,6 +11,8 @@ const defaultTsPluginOptions = { composite: false, exclude: ['**/*.stories.tsx', '**/*.test.ts', '**/*.test.tsx'], tsconfig: 'src/tsconfig.json', + sourceMap: true, + inlineSources: true } export default ({ diff --git a/yarn.lock b/yarn.lock index 534aaf19eb..9329064e75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13496,6 +13496,7 @@ __metadata: react-router-dom: 5.2.0 readable-stream: ^3.6.0 rxjs: 7.4.0 + source-map-loader: ^5.0.0 text-encoding-utf-8: ^1.0.2 tsconfig-paths-webpack-plugin: 3.5.2 webassembly-loader-sw: ^1.1.0 @@ -54800,6 +54801,18 @@ __metadata: languageName: node linkType: hard +"source-map-loader@npm:^5.0.0": + version: 5.0.0 + resolution: "source-map-loader@npm:5.0.0" + dependencies: + iconv-lite: ^0.6.3 + source-map-js: ^1.0.2 + peerDependencies: + webpack: ^5.72.1 + checksum: 66d6fbaa87a14197647515f274b9a685a84d0ddb95c3d9801bfb1ce28fc24000954c73548fe09c52c0bad660eb10d963b0c60d5c5943ccf2c8292a8d957f2acb + languageName: node + linkType: hard + "source-map-resolve@npm:^0.5.0": version: 0.5.3 resolution: "source-map-resolve@npm:0.5.3"