I have 2 projects, 1 project shared , there I store some files, which I want to reuse between projects, I have also project where I want to use this shared repo, I install it by using package.json, in next way
"dependencies": {
"shared": "git+https://username:token@git.domain.com/project/shared.git"
}
then it is installed in node_modules, it is ok until you don't check bundle size , it isn't optimized code, and webpack doesn't optimize it . I've tried to use some minimizers in shared repo for bebel compilation to make files size smaller, but it doesn't work a lot, here is the config :
module.exports = function(api) {
api.cache(true)
const presets = ['@babel/preset-env', '@babel/preset-react', 'minify']
const plugins = [
[
'module-resolver',
{
root: ['./src']
}
]
]
return {
presets,
plugins
}
}
Can I optimize it by using webpack in second project, or maybe there is some better way to make optimization in shared repository directly?
Also I use peer deps for preventing size increasing:
"peerDependencies": {
"@material-ui/core": "4.5.2",
"prop-types": "15.7.2",
"react": "16.11.0",
"react-dom": "16.11.0",
"react-helmet-async": "1.0.7",
"react-redux": "7.1.3",
"redux": "4.0.4",
"redux-form": "8.2.6",
"reselect": "4.0.0"
},
Also included only what need:
"files": [
"hooks",
"utils",
"constants",
"components",
"reducers",
"actions",
"selectors",
"README.md"
]
in package.json file.