I have this file:
AxiosExtension.js
import Axios from 'axios';
//eventually add code here, if I can get this simple file working
export default Axios;
I am running AxiosExtension through webpack babel loader that looks like this:
Webpack Babel-Loader
{
test: /\.js$/,
loader: 'babel-loader',
include: [
path.join(__dirname, '../../AxiosExtension'),
]
},
I am including AxiosExtension in multiple files like this:
MyCode.js
import Axios from 'path/to/file/AxiosExtension';
When I load MyCode.js in the browers after building my webpack, I get this error:
Console Error
Uncaught TypeError: window._interopRequireDefault is not a function
When I view my AxiosExtension.js file in Chrome Sources tab, here is what babel has output:
AxiosExtension.js Final Output after Babel
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _axios = require('axios');
window._axios2 = window._interopRequireDefault(_axios);
window._interopRequireDefault = function(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = window._axios2.default;
Looks like _interopRequireDefault
is defined after it is used. Any ideas about what might be wrong with my config of webpack/babel?
.babelrc
{
"presets": ["es2015"]
}