choko-org / redux-boot

Modular Redux bootstrap with asynchronous side-effects.
MIT License
126 stars 7 forks source link

Updated project to use redux as peerDependency. #28

Closed lucasconstantino closed 7 years ago

sebas5384 commented 7 years ago

@lucasconstantino thanks! moving everything to peerDependency was really needed.

Could you explain what are the benefits of that approach to build the dist bundle?

The build is failing since it couldn't find the webpack module in order to execute the build script, I'm going to analyze more about that and see if I can fix it.

lucasconstantino commented 7 years ago
  1. peerDependencies avoid that the dependency gets downloaded when you install redux-boot on another project. For testing purpose, I've add all peerDependencies as devDependencies as well.
  2. Webpack should not be used to generate the module file for it will invariably add unnecessary code and add dependencies to the bundled file. You could, though, make use of Webpack's library and externals to avoid such behavior, but for Node.js environments it's simply much easier to avoid Webpack and only compile the project's scripts so that projects can import them on node environments that do not support es6.

About Webpack failing in the build, I guess the CI is not installing devDependencies, is that rigth? It sure should for tests to work.

Ref: https://webpack.github.io/docs/library-and-externals.html

sebas5384 commented 7 years ago

@lucasconstantino the tests were failing since Babel's commands are separated in another module called babel-cli, adding the package to the devDependencies should work.

The change from Webpack to Babel made redux-boot dependent from babel-runtime module:

$ node index.js
module.js:341
    throw err;
    ^

Error: Cannot find module 'babel-runtime/regenerator'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/sebas/Virtual/projects/sebas-redux-boot/lib/bootstrap.js:8:20)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)

Maybe if we configure the Webpack to avoid the node_modules should do the trick, plus the peerDependencies change at the package.json file.

We could use Webpack Externals to create the lib/index.js bundle, or something like that.

What do you think?

[EDIT] Actually, I tested with webpack-node-externals and even so, the babe-runtime is always a dependency.