You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
Here b doesn't have a default export, but unwrapExports will dereference it anyway, since it has an __esModule property. Thus b$1, added as default on the final export object, is undefined.
Now if I try to use this as an external from a CJS file in another bundle, rollup will generate something like this for that import:
Which, since b has a default property which is undefined, will yield undefined.
I think the problem is in the code generating the unwrapExports call—that seems to be trying to add a 'fallback' default export in case this is a CommonJS module, but for an ES module that doesn't actually have a default export, no default export should be propagated.
Since you can't conditionally export stuff, and it looks like the information of whether there is an actual default export isn't available at the point where this code is generated (const defaultExport in transformCommonjs in src/transform.js), working around it at that point may be tricky.
Any ideas?
The text was updated successfully, but these errors were encountered:
Okay, a kludge that seems to work is to set defaultExport to the empty string when hasDefaultExport is false and this is an ES module. I've submitted #225 with such a patch, let me know whether it makes sense.
So that PR was not right, and the problem I touched on (not knowing in advance whether you need an export default at all) seems to be a good diagnosis of the problem. As a crude workaround, we could change the invocation in the consuming process to ignore undefined default exports
This seems to only cause problems in a slightly convoluted setup, but here goes:
I have a.js which is:
With b.js itself being rollup output, something like this:
If I roll up a.js with this plugin enabled, this is what comes out:
Here
b
doesn't have adefault
export, butunwrapExports
will dereference it anyway, since it has an__esModule
property. Thusb$1
, added asdefault
on the final export object, is undefined.Now if I try to use this as an external from a CJS file in another bundle, rollup will generate something like this for that import:
Which, since
b
has adefault
property which is undefined, will yield undefined.I think the problem is in the code generating the
unwrapExports
call—that seems to be trying to add a 'fallback' default export in case this is a CommonJS module, but for an ES module that doesn't actually have a default export, no default export should be propagated.Since you can't conditionally export stuff, and it looks like the information of whether there is an actual default export isn't available at the point where this code is generated (
const defaultExport
intransformCommonjs
in src/transform.js), working around it at that point may be tricky.Any ideas?
The text was updated successfully, but these errors were encountered: