Skip to content

Commit

Permalink
Revert "Enable source maps but exclude node modules"
Browse files Browse the repository at this point in the history
This reverts commit 38d454c.
  • Loading branch information
ferdinandsalis committed Jun 5, 2024
1 parent 38d454c commit c411d42
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 49 deletions.
16 changes: 0 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
import * as fs from 'fs'
import chalk from 'chalk'
import closeWithGrace from 'close-with-grace'
import sourceMapSupport from 'source-map-support'

sourceMapSupport.install({
retrieveSourceMap: function (source) {
// get source file without the `file://` prefix or `?t=...` suffix
const match = source.match(/^file:\/\/(.*)\?t=[.\d]+$/)
if (match) {
return {
url: source,
map: fs.readFileSync(`${match[1]}.map`, 'utf8'),
}
}
return null
},
})

closeWithGrace(async ({ err }) => {
if (err) {
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "UNLICENSED",
"scripts": {
"build": "run-s build:*",
"build:remix": "NODE_OPTIONS=--max-old-space-size=8192 remix vite:build --sourcemapClient --sourcemapServer",
"build:remix": "NODE_OPTIONS=--max-old-space-size=8192 remix vite:build",
"build:server": "tsx ./other/build-server.ts",
"dev": "node ./server/dev-server.js",
"format": "prettier --write .",
Expand Down Expand Up @@ -73,7 +73,6 @@
"sanity": "^3.45.0",
"sanity-plugin-media": "^2.2.5",
"slug": "^9.1.0",
"source-map-support": "^0.5.21",
"spin-delay": "^2.0.0",
"styled-components": "^6.1.11",
"tailwind-merge": "^2.3.0",
Expand Down
1 change: 0 additions & 1 deletion remix-0.cpuprofile

This file was deleted.

31 changes: 2 additions & 29 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,20 @@ import { flatRoutes } from 'remix-flat-routes'

const MODE = process.env.NODE_ENV

import type { Plugin } from 'vite'

interface SourcemapExclude {
excludeNodeModules?: boolean
}
export function sourcemapExclude(opts?: SourcemapExclude): Plugin {
return {
name: 'sourcemap-exclude',
transform(code: string, id: string) {
if (
(opts?.excludeNodeModules && id.includes('node_modules')) ||
id.includes('SanityVision') ||
id.includes('studio')
) {
return {
code,
// https://github.com/rollup/rollup/blob/master/docs/plugin-development/index.md#source-code-transformations
map: { mappings: '' },
}
}
},
}
}

// USAGE

export default defineConfig({
build: {
cssMinify: MODE === 'production',
rollupOptions: {
external: [/node:.*/, 'stream', 'crypto', 'fsevents'],
},
sourcemap: true,
sourcemap: false,
},
server: {
watch: {
ignored: ['**/playwright-report/**'],
},
},
plugins: [
sourcemapExclude({ excludeNodeModules: true }),

remix({
ignoredRouteFiles: ['**/*'],
serverModuleFormat: 'esm',
Expand Down Expand Up @@ -82,6 +54,7 @@ export default defineConfig({
},
},
sourcemaps: {
ignore: ['sanity'],
filesToDeleteAfterUpload: await glob([
'./build/**/*.map',
'.server-build/**/*.map',
Expand Down

0 comments on commit c411d42

Please sign in to comment.