Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not mutate browser source map object #2900

Merged
merged 1 commit into from
Sep 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions server/build/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,14 @@ export default async function createCompiler (dir, { buildId, dev = false, quiet
let output = transpiled.code

if (map) {
map.sources = map.sources.map((source) => source.replace(/\?entry/, ''))
delete map.sourcesContent
let nodeMap = Object.assign({}, map)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this can be just const since you're not reassigning the variable.

nodeMap.sources = nodeMap.sources.map((source) => source.replace(/\?entry/, ''))
delete nodeMap.sourcesContent

// Output explicit inline source map that source-map-support can pickup via requireHook mode.
// Since these are not formal chunks, the devtool infrastructure in webpack does not output
// a source map for these files.
const sourceMapUrl = new Buffer(JSON.stringify(map), 'utf-8').toString('base64')
const sourceMapUrl = new Buffer(JSON.stringify(nodeMap), 'utf-8').toString('base64')
output = `${output}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${sourceMapUrl}`
}

Expand Down