我使用ES6和meteor的ECMAScript包。我试图开发自己的软件包,遇到了一个我不知道如何进行调试的问题。
在我的包中,我有一个模块,它是主要入口点main.js
。在模块中,我导入了另一个模块import '../imports/startup/client/index.js';
在index.js
我导出一个函数函数。在我导出之前,我检查它是否已定义并且所有内容:
console.log(ExportedFunction)
export const Exportedfunction = ExportedFunction;
控制台返回:
ExportedFunction(opts) {
_classCallCheck(this, ExportedFunction);
然后在我的示例应用程序中,我尝试使用该导出:
import { Exportedfunction } from 'meteor/packageauthor:packagename'
console.log(Exportedfunction)
控制台返回:
undefined
所以某个地方的出口/进口中断,但我不知道如何找出原因。
调试此类故障的一般步骤是什么?
编辑:似乎在嵌套模块中导出是问题。如果我将相同的export const Exportedfunction = ExportedFunction;
带入main.js
而不是在index.js
中导入,那么一切正常。
为什么这和/或我如何解决这个问题,以便从其他模块导入的模块中导出?