Skip to content
New issue

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

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

Already on GitHub? # to your account

Handle sourcemaps #44

Merged
merged 6 commits into from
Oct 22, 2020
Merged
Changes from 2 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
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ module.exports = function svelte(options = {}) {
Object.assign(base_options, fixed_options, {
filename: id
}, major_version >= 3 ? null : {
name: capitalize(sanitize(id))
name: capitalize(sanitize(id)),
sourceMap: code.getMap ? code.getMap() : undefined
})
);

Expand Down Expand Up @@ -310,15 +311,15 @@ module.exports = function svelte(options = {}) {

if (chunk.map) {
const i = sources.length;
sources.push(chunk.map.sources[0]);
sourcesContent.push(chunk.map.sourcesContent[0]);
sources.push(...chunk.map.sources);
sourcesContent.push(...chunk.map.sourcesContent);

const decoded = decode(chunk.map.mappings);

if (i > 0) {
decoded.forEach(line => {
line.forEach(segment => {
segment[1] = i;
segment[1] += i;
});
});
}
Expand Down