Skip to content

Commit

Permalink
wip: use sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jun 16, 2023
1 parent c2e0149 commit 3e6073c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/vite/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function createCjsConfig(isProduction: boolean) {
...Object.keys(pkg.dependencies),
...(isProduction ? [] : Object.keys(pkg.devDependencies)),
],
plugins: [...createNodePlugins(false, false, false), bundleSizeLimit(120)],
plugins: [...createNodePlugins(false, false, false), bundleSizeLimit(150)],
})
}

Expand Down
11 changes: 10 additions & 1 deletion packages/vite/src/node/server/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
} from 'node:http'
import getEtag from 'etag'
import type { SourceMap } from 'rollup'
import MagicString from 'magic-string'
import { removeTimestampQuery } from '../utils'
import { getCodeWithSourcemap } from './sourcemap'

Expand Down Expand Up @@ -63,7 +64,15 @@ export function send(
}
} else {
if (type === 'js') {
content += `\n//# sourceURL=${removeTimestampQuery(req.url!)}`
const urlWithoutTimestamp = removeTimestampQuery(req.url!)
if (req.url! !== urlWithoutTimestamp) {
const ms = new MagicString(content.toString())
content = getCodeWithSourcemap(
type,
content.toString(),
ms.generateMap({ source: urlWithoutTimestamp, hires: true }),
)
}
}
}

Expand Down

0 comments on commit 3e6073c

Please sign in to comment.