Skip to content

Refactor platform reexports into explicit reexports#199

Merged
rolandszoke merged 1 commit intoRisingStack:tempfrom
orballo:named-exports
Jan 25, 2021
Merged

Refactor platform reexports into explicit reexports#199
rolandszoke merged 1 commit intoRisingStack:tempfrom
orballo:named-exports

Conversation

@orballo
Copy link

@orballo orballo commented Jul 11, 2020

Proposed changes

Refactor reexports from platforms/dom.js and platforms/native.js into explicit reexports.

Why

While trying to build my project with parcel and rollup I run into a situation where the bundlers cannot resolve the exports of these files. It has been a bit of a pain. As far as I know, parcel doesn't allow to manually fix this. On the other hand, rollup used to allow a manual fix with an option called namedExports which was deprecated in recent versions and it's no longer available.

Here is an example of the error I get from parcel (note: this only happens with parcel when using the --experimental-scope-hoisting flag, or with parcel v2):

🚨  ../node_modules/@risingstack/react-easy-state/dist/react-platform.js does not export 'unstable_batchedUpdates'
    at replaceExportNode (/Users/orballo/Code/mori/node_modules/parcel/src/scope-hoisting/concat.js:55:13)
    at ReferencedIdentifier (/Users/orballo/Code/mori/node_modules/parcel/src/scope-hoisting/concat.js:342:20)
    at newFn (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/visitors.js:220:17)
    at NodePath._call (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/path/context.js:55:20)
    at NodePath.call (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/path/context.js:42:17)
    at NodePath.visit (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/path/context.js:90:31)
    at TraversalContext.visitQueue (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/context.js:112:16)
    at TraversalContext.visitSingle (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/context.js:84:19)
    at TraversalContext.visit (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/context.js:140:19)
    at Function.traverse.node (/Users/orballo/Code/mori/node_modules/@babel/traverse/lib/index.js:84:17)

Regarding rollup I found this issue (rollup/rollup#2671). After asking, they suggested that all the reexports should be explicit to avoid this kind of problems.

I'm not sure if this is the ideal solution (I wasn't able to fix it in any other way, though), but if it has no downsides, this changes will at least prevent some pain.

Let me know what you think or if I need to do any further changes.

@orballo orballo changed the title refactor(platform): change exports so parcel and rollup can solve them Refactor platform reexports into explicit reexports Jul 11, 2020
@rolandszoke
Copy link
Member

@orballo Thanks for the fix! 🚀 We will merge your commits to the temp branch along with other changes, so we can make sure everything works fine (tests and build process), and eventually (probably this week) we will release it to alpha.

@rolandszoke rolandszoke changed the base branch from master to temp January 25, 2021 14:56
@rolandszoke rolandszoke merged commit 13b0835 into RisingStack:temp Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants