"scripts": {
"compile": "cross-env NODE_ENV=production babel src --out-dir ."
},
"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"
},
strong text
babel.config.js
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
}
}
Above you can see files structure, package.json and babel configurations , before pushing it to repository , I do npm run compile , it compile files from src folder to root, then I push it to repository, below you can see how I install it in other project
"dependencies": {
"shared": "git+https://usernma:token@git.allnewsmartadmin.com/project/shared.git",
}
then when I need some code from shared , I do import someModule from 'shared/action/someModule.js' . All is great , but by using it in this way , my bundle size increated a lot , and increased vendor.js file, because webpack detect really massive node_modules module . How can I compile it to make code in shared repository be as much small as it possible with bable ?