Closed marijnh closed 5 years ago
(Found a workaround with the externalLiveBindings: false
option to Rollup, so if this is hard to support, I can live with a wontfix answer.)
You need explicitly specify named exports of this package. This is the way I use in my app for react package
import react from 'react';
commonjs({
namedExports: {
'react': Object.keys(react)
}
})
Closing as duplicate of #159, please move any discussion over there!
FWIW rollup recognizing its own CJS in a mirror seems like a worthwhile enhancement, but these dynamic patterns are generally difficult to tease out reliably. namedExports
is going to be the right solution (and @TrySound's dynamic approach seems really cool, I may adopt it 👍)
If you run rollup (generating CommonJS) on something like
export {Foo} from "foo"
while marking"foo"
as external, you get code like this:But when you then try to consume the resulting package via rollup-plugin-comonjs, it'll complain
Is there something I'm doing wrong? Is it unreasonable to expect Rollup's CommonJS output to be recognized by this plugin?