New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syntheticNamedExport export is appears in renderedExports, even it's not rendered actually #3857
Comments
Exactly. It is only exposed if used. The reason is that this is a central feature for the commonjs plugin, and we do not want to pollute entry points with the artificial |
Ok, so I think it can be fixed by adding additional field with ectual SNE export name to But what with reexport-all from modules with SNE? It breaks entry signatures too and even not warned by rollup. Even without entry signatures it can easly break code when one module reexports all from SNE-module and then third module trying to export some (valid) name from that reexport. |
We can either just forbid to reexport-all from a SNE-module, or "pollute" SNE in that case (and throws if importer module already have SNE, or even merge them). But at least warning is needed. |
Please give this a shot, Rollup should handle that nicely for internal imports. It is only if an entry module is reexporting the namespace of a module with synthetic exports. In that case, the synthetic exports are completely ignored. But in my eyes, this is completely consistent with the synthetic export being omitted if the module itself is the entry point. |
Not only entry modules, but any module. Just look at https://repl.it/repls/RemarkableSlipperyRam#input.js |
Ah I see. So you are importing from a module without synthetic exports that reexports from a module that has synthetic exports. I am sure this case was not considered. Looks like a bug to be fixed. |
Ok, so I returned to this issue. There is second case, which is described in top post, but not discussed. https://repl.it/@Amareis/RemarkableSlipperyRam const t = {q: 1}
export {t as __moduleExports} //__moduleExports is marked as synthetic export This file is not entry. After translating with |
#3894 contains a fix for the bug concerning namespace reexports you mentioned earlier, please have a look. |
Expected Behavior
Synthetic export should not be dropped until it's unused and treeshaking is on.
Actual Behavior
Even with disabled treeshaking and minifyInternalExports, export is dropped. It can break the entry signature, as in example. Also, SNE export is appears in
OutputChunk.modules.renderedExports
, but it doesn't rendered actually.As I see, it's happened here: https://github.com/rollup/rollup/blob/master/src/Module.ts#L396
I commented that line and all is fine - even tests is not broken.
It's not treeshaked, even if not used. In commonjs module, where
__moduleExports
it's just reexporteddefault
, rollup uses thisdefault
, but don't remove__moduleExports
, but as I see it's just current rollup behaviour: don't drop export statement, if it's reexport of included variable, even if export itself is not used.The text was updated successfully, but these errors were encountered: