0
我的代碼是:出口是空的,browserify
的src/index.js
const myObject = {
name : "Object",
fun : function() {
console.log('Do some simple stuff');
},
data: "some data"
};
export default myObject;
與browserify結果很簡單:
(function e(t,n,r){function s(o,u) ...
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) .....
var myObject = {
name: "Object",
fun: function fun() {
console.log('Do some simple stuff');
},
data: "some data"
};
var X = function X() {
_classCallCheck(this, X);
};
exports.default = myObject;
//export default exposed;
},{}]},{},[1]);
在main.js,使用瀏覽爲模塊:
var x = require('./index');
console.log(x); // <--- empty object
必須有一些愚蠢的事我已經錯過:(