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

Fix sourcemaps failing on refresh #1755

Merged
merged 2 commits into from Jul 22, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/SourceMap.js
@@ -1,5 +1,6 @@
const {SourceMapConsumer, SourceMapGenerator} = require('source-map');
const lineCounter = require('./utils/lineCounter');
const clone = require('clone');

class SourceMap {
constructor(mappings, sources) {
Expand Down Expand Up @@ -38,6 +39,8 @@ class SourceMap {
}

async addMap(map, lineOffset = 0, columnOffset = 0) {
map = clone(map);
Copy link
Member

Choose a reason for hiding this comment

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

what kind of perf impact does this have? is there a specific situation where we need to clone, or just all the time?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could probably move it to before line 62, as the actual reuse of mappings happens on the lines after that as far as I know. I haven't tested moving it, but it should work in theory

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not able to compare performance as I don't really have a project which is big enough to notice a difference


if (!(map instanceof SourceMap) && map.version) {
let consumer = await this.getConsumer(map);

Expand Down