Answer the question
In order to leave comments, you need to log in
Weback + Babel: Modules not being exported?
Why can't I export anything from the index.js file, which is collected in dist, in webpack via babel, that is, I take for example in src/index.js I write export const { name: 'Mike }
that when compiling into a bundle and connecting this file, I get an empty object?
I understand this is a problem with babel
here is my webpack config:
const path = require('path')
const webpackConfig = {
entry: {
index: path.resolve(__dirname, '../src', 'index.js'),
main: path.resolve(__dirname, '../src', 'main.js'),
test: path.resolve(__dirname, '../src', 'test.js')
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../dist')
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
]
}
}
module.exports = {
presets: [
'@babel/preset-env'
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-async-to-generator'
]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question