directory structure is as follows
Code
profile.js
function showMsg(msg) {
alert(msg);
}
export default {showMsg};
import.js
import {showMsg} from "./profile.js";
showMsg("hello world");
.babelrc
{
"presets":[
"es2015"
],
"plugins":["transform-es2015-modules-umd"]
}
package.json
{
"name": "module",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src/import.js -o dist/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-preset-es2015": "^6.24.1"
}
}
prompt Cannot read property "showMsg" of undefined after running