redux-saga: Bundling with Rollup fails due to missing export
Hello,
i’m trying to bundle my project using redux-saga and stumbled upon an issue.
using the node-resolve plugin for rollup and the { jsnext: true } option gives me the following error:
'CHANNEL_END' is not exported by '$PATH_TO_PROJECT$\node_modules\redux-saga\es\internal\io.js' (imported by '$PATH_TO_PROJECT$\node_modules\redux-saga\es\utils.js') Error: 'CHANNEL_END' is not exported by '$PATH_TO_PROJECT$\node_modules\redux-saga\es\internal\io.js' (imported by '$PATH_TO_PROJECT$\node_modules\redux-saga\es\utils.js') at Module.traceExport ($PATH_TO_PROJECT$\node_modules\rollup\src\Module.js:376:17) ...
Looking at the es/internal/io.js module there is no export for this but the es/utils.js re-exports this constant.
es/utils.js
export { CHANNEL_END, asEffect } from './internal/io';
Setting the { jsnext: false } option solves the issue as a workaround but also disables all other es6 imports.
Did I miss something or is this a small bug?
Thanks in advance.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 48 (37 by maintainers)
Commits related to this issue
- Fixes CHANNEL_END public export (fixes #689) — committed to redux-saga/redux-saga by Andarist 8 years ago
- Fixes CHANNEL_END public export (fixes #689) — committed to redux-saga/redux-saga by Andarist 8 years ago
- Fixes CHANNEL_END public export (fixes #689) — committed to redux-saga/redux-saga by Andarist 8 years ago
- Merge pull request #690 from yelouafi/fix/channel-end-import Fixes CHANNEL_END public export (fixes #689) — committed to redux-saga/redux-saga by Andarist 8 years ago
- Reworked take/takem handling internally a little bit, so its more clear. Also it should fix #689 — committed to redux-saga/redux-saga by Andarist 8 years ago
thanks to @Ephys I’ll release a patch version today which should fix this problem entirely and fixes/hacks like:
redux-saga-effectspackageeffectsfromredux-sagashould become obsolete 🎉
@zech @ok111net - please check out the new release and let me know
The solution of splitting the lib into separate modules and have them required by each other if neccessary - monorepo style - seems the most viable.
@zech how would it mix up es6 and es5 code during the build? what do you mean?
bug with wrong import doesn’t affect webpack 1 and webpack 2 users - use both of them on different project, all as expected.
the main problem is to have 2 entry points while all build systems expect only 1 main file. At least two approaches coming to my mind:
redux-sagapackage into two:redux-saga-coreandredux-saga-effects(naming is just example)Ok, I think I know why this happens, but aint sure how it should be solved.
redux-saga/effectsis interpreted as node_module, so its traversing the directory tree and searches for that using this https://github.com/substack/node-resolve/blob/7f0ce871b6d2b5cb2082b04cd72ddd4055cb7a05/lib/async.js#L172lib) folderIn case of
redux-sagaitself it finds a correct directory and rollup later concatanates path withjsnext:mainoption. But its not working witheffects.jsfor quite obvious reasons.Ill try to reach out to rollup users so it can be handled in a better way.
@yelouafi I’ve always wondered about dir structure in the repo, could you elaborate a little bit more on it? Ive always assumed that
webpackwhen importingredux-saga/effectsis reaching for./lib/effects.jsbut it might seem (didnt check it though) that its reaching for./effects.jsand this only acts as a ‘proxy’ to the beforementioned file. Its kinda non obvious at first and Im wondering if maybe it could be somehow organised better as this ‘proxy’ seems a little bit hacky