From bba856fcadb1c3e6d3bdea3387cb8c382553b480 Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Tue, 17 Dec 2024 15:54:06 -0500 Subject: [PATCH] Enable separate source maps for all package builds (#2088) ## Motivation for the change, related issues Enabling source map generation for production builds would make it easier to debug Playground in production. ## Implementation details I edited all vite.config.js files and added `sourcemap: true` to generate separate source maps files for all package builds. Keeping separate source maps should allow us to only pay the cost for downloading them when actively debugging. ## Testing Instructions (or ideally a Blueprint) - Create a production build, serve it via a local web server, open dev tools, and confirm it is possible to view the original source code. - CI --- packages/php-wasm/cli/vite.config.ts | 1 + packages/php-wasm/fs-journal/vite.config.ts | 1 + packages/php-wasm/logger/vite.config.ts | 1 + packages/php-wasm/node-polyfills/vite.config.ts | 1 + packages/php-wasm/node/vite.config.ts | 1 + packages/php-wasm/progress/vite.config.ts | 1 + packages/php-wasm/scopes/vite.config.ts | 1 + packages/php-wasm/stream-compression/vite.config.ts | 1 + packages/php-wasm/universal/vite.config.ts | 1 + packages/php-wasm/util/vite.config.ts | 1 + packages/php-wasm/web/vite.config.ts | 1 + packages/playground/blueprints/vite.config.ts | 1 + packages/playground/cli/vite.config.ts | 1 + packages/playground/common/vite.config.ts | 1 + packages/playground/components/vite.config.ts | 1 + packages/playground/remote/vite.config.ts | 1 + packages/playground/storage/vite.config.ts | 1 + packages/playground/sync/vite.config.ts | 1 + packages/playground/website/vite.config.ts | 1 + packages/playground/wordpress-builds/vite.config.ts | 1 + packages/playground/wordpress/vite.config.ts | 1 + 21 files changed, 21 insertions(+) diff --git a/packages/php-wasm/cli/vite.config.ts b/packages/php-wasm/cli/vite.config.ts index 385e451e7e..1b8c1801c0 100644 --- a/packages/php-wasm/cli/vite.config.ts +++ b/packages/php-wasm/cli/vite.config.ts @@ -14,6 +14,7 @@ export default defineConfig(() => { build: { assetsInlineLimit: 0, target: 'es2020', + sourcemap: true, rollupOptions: { external: [ '@php-wasm/node', diff --git a/packages/php-wasm/fs-journal/vite.config.ts b/packages/php-wasm/fs-journal/vite.config.ts index 23144abf1b..57884f30f5 100644 --- a/packages/php-wasm/fs-journal/vite.config.ts +++ b/packages/php-wasm/fs-journal/vite.config.ts @@ -34,6 +34,7 @@ export default defineConfig({ fileName: 'index', formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/logger/vite.config.ts b/packages/php-wasm/logger/vite.config.ts index ef523308fa..226cc2ae83 100644 --- a/packages/php-wasm/logger/vite.config.ts +++ b/packages/php-wasm/logger/vite.config.ts @@ -34,6 +34,7 @@ export default defineConfig({ fileName: 'index', formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/node-polyfills/vite.config.ts b/packages/php-wasm/node-polyfills/vite.config.ts index 476448d6f4..1cf91ea110 100644 --- a/packages/php-wasm/node-polyfills/vite.config.ts +++ b/packages/php-wasm/node-polyfills/vite.config.ts @@ -37,6 +37,7 @@ export default defineConfig({ // Don't forget to update your package.json as well. formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/node/vite.config.ts b/packages/php-wasm/node/vite.config.ts index 69bfdf914b..2304035557 100644 --- a/packages/php-wasm/node/vite.config.ts +++ b/packages/php-wasm/node/vite.config.ts @@ -29,6 +29,7 @@ export default defineConfig(function () { fileName: 'index', formats: ['es'], }, + sourcemap: true, rollupOptions: { // Don't bundle the PHP loaders in the final build. See // the preserve-php-loaders-imports plugin above. diff --git a/packages/php-wasm/progress/vite.config.ts b/packages/php-wasm/progress/vite.config.ts index 747b5beb99..ffaeab8e4b 100644 --- a/packages/php-wasm/progress/vite.config.ts +++ b/packages/php-wasm/progress/vite.config.ts @@ -45,6 +45,7 @@ export default defineConfig({ // Don't forgot to update your package.json as well. formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/scopes/vite.config.ts b/packages/php-wasm/scopes/vite.config.ts index 2d1fcfdfd6..616a0fc19b 100644 --- a/packages/php-wasm/scopes/vite.config.ts +++ b/packages/php-wasm/scopes/vite.config.ts @@ -34,6 +34,7 @@ export default defineConfig({ fileName: 'index', formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/stream-compression/vite.config.ts b/packages/php-wasm/stream-compression/vite.config.ts index 8644a778ca..060c754b2c 100644 --- a/packages/php-wasm/stream-compression/vite.config.ts +++ b/packages/php-wasm/stream-compression/vite.config.ts @@ -38,6 +38,7 @@ export default defineConfig({ // Don't forget to update your package.json as well. formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/universal/vite.config.ts b/packages/php-wasm/universal/vite.config.ts index b7c64ad708..9bd2fb8ae4 100644 --- a/packages/php-wasm/universal/vite.config.ts +++ b/packages/php-wasm/universal/vite.config.ts @@ -34,6 +34,7 @@ export default defineConfig({ fileName: 'index', formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/util/vite.config.ts b/packages/php-wasm/util/vite.config.ts index 59d0e3dd1b..a03eecbf08 100644 --- a/packages/php-wasm/util/vite.config.ts +++ b/packages/php-wasm/util/vite.config.ts @@ -40,6 +40,7 @@ export default defineConfig({ fileName: 'index', formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/php-wasm/web/vite.config.ts b/packages/php-wasm/web/vite.config.ts index 5f8131fdb4..c4ed63aff7 100644 --- a/packages/php-wasm/web/vite.config.ts +++ b/packages/php-wasm/web/vite.config.ts @@ -80,6 +80,7 @@ export default defineConfig(({ command }) => { fileName: 'index', formats: ['es'], }, + sourcemap: true, rollupOptions: { // Don't bundle the PHP loaders in the final build. See // the preserve-php-loaders-imports plugin above. diff --git a/packages/playground/blueprints/vite.config.ts b/packages/playground/blueprints/vite.config.ts index 50cc8d70d4..045a50d817 100644 --- a/packages/playground/blueprints/vite.config.ts +++ b/packages/playground/blueprints/vite.config.ts @@ -45,6 +45,7 @@ export default defineConfig({ // Don't forgot to update your package.json as well. formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { external: getExternalModules(), }, diff --git a/packages/playground/cli/vite.config.ts b/packages/playground/cli/vite.config.ts index 546ad0bf63..e5c7de03c1 100644 --- a/packages/playground/cli/vite.config.ts +++ b/packages/playground/cli/vite.config.ts @@ -13,6 +13,7 @@ export default defineConfig({ build: { assetsInlineLimit: 0, target: 'es2020', + sourcemap: true, rollupOptions: { external: [ '@php-wasm/node', diff --git a/packages/playground/common/vite.config.ts b/packages/playground/common/vite.config.ts index f7854f9f82..4b8b886d44 100644 --- a/packages/playground/common/vite.config.ts +++ b/packages/playground/common/vite.config.ts @@ -26,6 +26,7 @@ export default defineConfig({ // in the app mode. // @see https://github.com/vitejs/vite/issues/3295 assetsInlineLimit: 0, + sourcemap: true, rollupOptions: { input: path('src/index.ts'), // These additional options are required to preserve diff --git a/packages/playground/components/vite.config.ts b/packages/playground/components/vite.config.ts index 44da88e73a..95d36a83ca 100644 --- a/packages/playground/components/vite.config.ts +++ b/packages/playground/components/vite.config.ts @@ -41,6 +41,7 @@ export default defineConfig({ // Don't forgot to update your package.json as well. formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { external: getExternalModules(), }, diff --git a/packages/playground/remote/vite.config.ts b/packages/playground/remote/vite.config.ts index 9823bd9ec9..815181e7ae 100644 --- a/packages/playground/remote/vite.config.ts +++ b/packages/playground/remote/vite.config.ts @@ -92,6 +92,7 @@ export default defineConfig({ // in the app mode. // @see https://github.com/vitejs/vite/issues/3295 assetsInlineLimit: 0, + sourcemap: true, rollupOptions: { input: { wordpress: path('/remote.html'), diff --git a/packages/playground/storage/vite.config.ts b/packages/playground/storage/vite.config.ts index 43ea5f91ab..bef21515a8 100644 --- a/packages/playground/storage/vite.config.ts +++ b/packages/playground/storage/vite.config.ts @@ -37,6 +37,7 @@ export default defineConfig({ // Don't forgot to update your package.json as well. formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/playground/sync/vite.config.ts b/packages/playground/sync/vite.config.ts index 7e52707278..73f9135bbc 100644 --- a/packages/playground/sync/vite.config.ts +++ b/packages/playground/sync/vite.config.ts @@ -37,6 +37,7 @@ export default { // Don't forgot to update your package.json as well. formats: ['es', 'cjs'], }, + sourcemap: true, rollupOptions: { // External packages that should not be bundled into your library. external: getExternalModules(), diff --git a/packages/playground/website/vite.config.ts b/packages/playground/website/vite.config.ts index b655518984..b973bb0c06 100644 --- a/packages/playground/website/vite.config.ts +++ b/packages/playground/website/vite.config.ts @@ -170,6 +170,7 @@ export default defineConfig(({ command, mode }) => { // See: https://vitejs.dev/guide/build.html#library-mode build: { target: 'esnext', + sourcemap: true, rollupOptions: { input: { index: fileURLToPath( diff --git a/packages/playground/wordpress-builds/vite.config.ts b/packages/playground/wordpress-builds/vite.config.ts index 1385087e4e..fbd52642c2 100644 --- a/packages/playground/wordpress-builds/vite.config.ts +++ b/packages/playground/wordpress-builds/vite.config.ts @@ -49,6 +49,7 @@ export default defineConfig({ // in the app mode. // @see https://github.com/vitejs/vite/issues/3295 assetsInlineLimit: 0, + sourcemap: true, rollupOptions: { external: getExternalModules(), input: path('src/index.ts'), diff --git a/packages/playground/wordpress/vite.config.ts b/packages/playground/wordpress/vite.config.ts index d1b04510c4..edfb390862 100644 --- a/packages/playground/wordpress/vite.config.ts +++ b/packages/playground/wordpress/vite.config.ts @@ -49,6 +49,7 @@ export default defineConfig({ // in the app mode. // @see https://github.com/vitejs/vite/issues/3295 assetsInlineLimit: 0, + sourcemap: true, rollupOptions: { input: path('src/index.ts'), external: getExternalModules(),