Im trying to set up my project with webpack, i've read about code-splitting and i am trying to make two separate bundles, one for the actual application code and the other for libraries and frameworks. So my webpack config looks like this:
entry: {
app: './app/index.js',
vendor: './app/vendor.js'
},
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'public/js')
},
watch: true,
module: {
rules: [{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: 'css-loader'
})
}]
},
plugins: [
new ExtractTextPlugin('styles.css'),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
})
]
in my vendor.js bundle i have only one line:
import moment from 'moment';
And when i try to use it in my app.js file it tells me, that moment is not defined. So, the thing that i don't get, do bundles have common scope or not? If not, then how can i access variables that i've exported in another bundle and if i can't, then what's even the point of having the vendor bundle like described here https://webpack.js.org/guides/code-splitting-libraries/ ?
moment jsin node_modules? how do you usevendor.jsinindex.js- Tom Sarduy