Skip to content
Open
Show file tree
Hide file tree
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
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()) {
Copy link
Member

Choose a reason for hiding this comment

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

No need to wrap this with hasDebugFlag(). That check is already part of logTransform.

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