我正在寫一個使用ES6的流星應用程序,我有一些子組件,我想保留爲獨立的npm軟件包。我有一個名爲frog-utils的庫,它在所有包中共享,並且包含通用的幫助函數。流星找不到再出口模塊
當我嘗試重新導出模塊青蛙-utils的,它正常工作與普通節點,但流星抱怨說:
W20161114-10:12:17.483(1)? (STDERR) Error: Cannot find module './color_range'
W20161114-10:12:17.484(1)? (STDERR) at require (packages/modules-runtime.js:109:19)
W20161114-10:12:17.484(1)? (STDERR) at meteorInstall.node_modules.frog-utils.dist.index.js (packages/modules.js:17407:20)
(這裏是從普通節點爲例,在相同的目錄)
~/s/F/frog (ac-collab) $ node
> frogutils = require('frog-utils')
{ color_range: [Getter],
uuid: [Function: uuid],
currentDate: [Function: currentDate],
booleanize: [Function: booleanize],
shorten: [Function: shorten],
compose: [Function: compose],
composeReducers: [Function: composeReducers],
notEmpty: [Function: notEmpty],
identity: [Function: identity],
getKey: [Function: getKey] }
我寫在ES6,用巴貝爾創造其由模塊暴露出的輸出文件,和ES5似乎沒什麼問題:
var _color_range = require('./color_range');
Object.defineProperty(exports, 'color_range', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_color_range).default;
}
});
(這是我使用ES6線)
export {default as color_range} from './color_range'
謝謝,但我確實指定我使用Babel編譯到ES5,所以這不是問題。 –