question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ship a module build

See original GitHub issue

If you look at the latest commonJS build, you’ll see this require statement:

var _reduxActions = require("redux-actions");

This imports all of redux-actions – which doesn’t sound like a lot, but they depend a lot of utilities, for example, lodash.curry – which is 33kb. Only createAction and handleActions are imported. (A different function in the redux-actions library imports lodash.curry).

I propose we ship a module build. Module builds are just like commonjs builds, except they use ES Module import syntax – which is important for tree-shaking.

It’s 100% backwards-compatible. You’d add a “module” property to package.json to point to the ES module build. Then people using tools like rollup and webpack will get the benefits of treeshaking awesomeness.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
petermikitshcommented, Sep 28, 2018

Everything will still ship as one NPM module. I meant two libraries within the existing feathers-redux NPM module: the (existing) commonjs build and an additional esmodule build.

It’s best to use the main and module package.json fields to point to the commonjs and esmodule builds (respectively). This allows for better support of the module in server and client environments.

For example, suppose in source code you were require feathers-redux/commonjs/index.js or feathers-redux/esmodule/index.js. If you’re compiling the code on the client, and you pick the esmodule build, then you get the tree shaking awesomeness. But if you’re using the module on the server (which in this case, is possible because of server-side rendering), you need to compile your server code (since NodeJS core doesn’t support import-syntax).

If the package author declares defines main and module fields in package.json, you just import feathers-redux, and based off of your environment and build tools, you will automatically resolve to the commonjs or esmodule build.

I’ll do a PR for it soon. Since it’s totally backwards compatible and won’t break anyone, I think you’ll be happy to accept it.

0reactions
petermikitshcommented, Jun 10, 2019

@abecks I’ve opened https://github.com/feathers-plus/feathers-redux/pull/60.

This probably isn’t as beneficial as it would’ve been before, but it would still be a good addition. When I opened this issue, redux-actions was much larger:

Screen Shot 2019-06-09 at 8 56 45 PM

At the time, v2.6.1 was the latest release (18.7kB / 6.9kB). The latest release, v2.6.5 is 7kB / 2.7kB.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create, build and ship a Python3 pip module in 5 minutes
Let's ship some modules. Shipping pip packages — the automated way. Prerequisites. PyPi account. Register here and save your credentials in a ...
Read more >
Modularisation - Establishing New Ship Building Mindsets ...
“In essence, the project is about how to build the same ship for different purposes – creating one ship family for three different...
Read more >
T1 Ship and Module Production - EVE HOW TO
T1 ships and modules only need the most basic raw materials to build, which are minerals. These are gathered in form of ore...
Read more >
help with ship building : r/playatlas - Reddit
Wikipedia seems to be completely outdated about the ship building ... me to progress into a ship I can actually edit and attach...
Read more >
Submitting module builds in Fedora
fedpkg module-build requires an authorization to MBS. Fedora infrastructure uses OpenID Connect ... Generally, in Fedora we do not ship the -devel modules....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found