Closed ryan-roemer closed 6 years ago
Webpack tree-shaking at least as of 3.10 just isn't working is the short answer. I have a new experiment repository up at: https://github.com/FormidableLabs/rlr-tree-shaking-experiment
3.10
This mean a couple of things:
import { something } from 'redux-little-router'
The present workaround to all of this is one-off imports, which means something like instead of:
import { routerForBrowser } from 'redux-little-router';
do:
import routerForBrowser from 'redux-little-router/es/environment/browser-router';
in your frontend code and:
import routerForBrowser from 'redux-little-router/lib/environment/browser-router';
in your node code.
This is problematic for universal code which instead should probably do something like:
import routerForBrowser from 'redux-little-router/environment/browser-router';
in universal code and something like:
const path = require('path'); alias: { 'redux-little-router': path.dirname(require.resolve('redux-little-router/es/index')) }
in webpack config.
immutable
src/immutable/index.js
src/index.js
/cc @tptee
Fixed in https://github.com/FormidableLabs/redux-little-router/releases/tag/v15.0.0 with the caveat that you need webpack@4+.
webpack@4+
Overview
Webpack tree-shaking at least as of
3.10
just isn't working is the short answer. I have a new experiment repository up at: https://github.com/FormidableLabs/rlr-tree-shaking-experimentThis mean a couple of things:
import { something } from 'redux-little-router'
is likely getting a lot more code and maybe even other dependencies than they should.Workarounds
The present workaround to all of this is one-off imports, which means something like instead of:
do:
in your frontend code and:
in your node code.
This is problematic for universal code which instead should probably do something like:
in universal code and something like:
in webpack config.
Task
immutable
things tosrc/immutable/index.js
instead ofsrc/index.js
/cc @tptee