Skip to content

Commit

Permalink
Handle JSON string source maps returned from rollup plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeriit committed Jul 27, 2021
1 parent fd94818 commit c02209b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-shrimps-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wmr': patch
---

Handle JSON string source maps returned from rollup plugins
12 changes: 12 additions & 0 deletions packages/wmr/src/lib/rollup-plugin-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ export function createPluginContainer(plugins, opts = {}) {

logTransform(`${kl.dim(formatPath(id))} [${plugin.name}]`);
if (typeof result === 'object') {
if (typeof result.map === 'string') {
try {
result.map = JSON.parse(result.map);
} catch {
if (hasDebugFlag()) {
logTransform(kl.yellow(`Invalid source map JSON returned by plugin `) + kl.magenta(plugin.name));
}

result.map = undefined;
}
}

if (result.map) {
// Normalize source map sources URLs for the browser
result.map.sources = result.map.sources.map(s => {
Expand Down

0 comments on commit c02209b

Please sign in to comment.