I am using webpack, ES6, and Babel for a project. A module had a require statement like so:
var ajaxGetJSON = require("../utils/ajaxGetJSON");
The bundle compiled fine but threw a runtime error that
Uncaught TypeError: ajaxGetJSON is not a function
Here is an examination of the object provided by webpack to my module:
When I change the require to an import ajaxGetJSON from "../utils/ajaxGetJSON";
the runtime error does not occur and the inspected object that should be the function ajaxGetJSON
works properly.
The ajax module uses export default myObject
.
Why does switching to an import fix my problem?