Can't bundle with React-Router
salztorte opened this issue · 3 comments
Can't bundel react-router because of
Cannot overwrite the same content twice: 'invariant'
In the other issues we found out that this is a Problem with the rollup-plugin-replace and the react-router
The main problem here is using nested ternary operators. If you replace line like this in react-router (Redirect.js, IndexRedirect.js, Route.js and IndexRoute.js):
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<Route> elements are for router configuration only and should not be rendered') : invariant(false) : undefined;
by if statements
if (!false) {
if (process.env.NODE_ENV !== 'production') {
invariant(false, '<Route> elements are for router configuration only and should not be rendered');
} else {
invariant(false);
}
} else {
undefined;
}
rollup will bundle your code without errors.
Don't know if it is really rollup-plugin-replace issue...
Just made small rollup plugin to convert ternary expressions to if statements: https://github.com/nashdot/rollup-plugin-ternary (conversion is not perfect yet...)
Using it correct your problem: https://github.com/nashdot/RollupReactRouter
Hey folks. This is a saved-form message, but rest assured we mean every word. The Rollup team is attempting to clean up the Issues backlog in the hopes that the active and still-needed, still-relevant issues bubble up to the surface. With that, we're closing issues that have been open for an eon or two, and have gone stale like pirate hard-tack without activity.
We really appreciate the folks have taken the time to open and comment on this issue. Please don't confuse this closure with us not caring or dismissing your issue, feature request, discussion, or report. The issue will still be here, just in a closed state. If the issue pertains to a bug, please re-test for the bug on the latest version of Rollup and if present, please tag @wesleygrimes and request a re-open, and we'll be happy to oblige.