Skip to content
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

Improve packaging: webpack uses UMD build, inlines immer, selectorator, etc. #55

Closed
exogen opened this issue Dec 10, 2018 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@exogen
Copy link
Contributor

exogen commented Dec 10, 2018

The goal: Ideally, if I only import createAction then I wouldn't expect immer or selectorator to be pulled into my bundle. This is the intention behind the ESM build pointed to by the module field in this library's current package.json.

Unfortunately, webpack in its default configuration (including how it's configured in frameworks like Next.js) prefers the browser field to module, so the entire 103KB UMD build is pulled in no matter what you import. Instead of requiring people to fiddle with a non-default webpack config, it would be better to behave nicely with the defaults.

If you check out the package.json for redux and react-redux, they don't specify the browser field at all – instead, the UMD build is linked in the unpkg field. That way, webpack will prefer the module build but there's still a UMD build included.

This comment also suggests a potential way that these fields could behave together, by providing browser alternatives to both the ESM and CJS entry points. I'm not sure how that works exactly, but might be worth exploring.

@markerikson
Copy link
Collaborator

This should be resolved in https://github.com/reduxjs/redux-starter-kit/releases/tag/v0.3.2 .

@markerikson
Copy link
Collaborator

Hmm. I take that back - the fix in 0.3.2 resolved the UMD build issue, but I also see the rest of the libs getting pulled into the output.

Per the example from #68 , import {getDefaultMiddleware} from "redux-starter-kit" in a CRA project and building it results in folders like redux/es, redux-thunk/es, immer/dist, and redux-immutable-state-invariant showing up in the sourcemap, indicating they got pulled in.

I assume this is because we're pulling it from the RSK index file, and that's causing things to not get tree-shaken.

I don't even pretend to understand what contortions you have to go through these days to get tree shaking to work properly. Open to suggestions :)

@markerikson
Copy link
Collaborator

Based on what I'm seeing in the 1.3 alphas, pretty sure this is fixed by now.

markerikson pushed a commit that referenced this issue Apr 20, 2021
…seQuery (#55)

* Add prepareHeaders
* Update QueryApi types and tests
* Update buildThunks
* Add auth example and token usage to examples
* Fix Matcher types, add an example of `extraReducers` with a matcher

Co-authored-by: Lenz Weber <mail@lenzw.de>
Co-authored-by: Matt Sutkowski <msutkowski@gmail.com>
phryneas pushed a commit that referenced this issue Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants