[英]When writing an ES6 module and converting to CommonJS, no specified exports are actually being exported
I have an ES6 module from which I'm trying to export several functions. 我有一个ES6模块,试图从中导出几个功能。 End goal is to import into purescript, but right now my supposedly exported functions don't even appear in Node, and I cannot understand why.
最终目标是导入到purescript中,但是现在我所谓的导出函数甚至都没有出现在Node中,我也不明白为什么。
Here is the module: 这是模块:
"use strict";
const point = (x, y) => new Point(x, y)
const pointToString = (point) => point.toString()
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
toString () {
return `(${this.x}, ${this.y})`;
}
}
export { point, pointToString }
I transpile it like so: 我像这样转换它:
browserify src/page.js -t [ babelify --presets [es2015] ] > src/Page.js
And then I try to load it into Purescript and Node. 然后,我尝试将其加载到Purescript和Node中。 Purescript reports that
point
and pointToString
are not defined. Purescript报告未定义
point
和pointToString
。 The Node session looks like this: Node会话如下所示:
> require("./src/Page.js")
{}
> require("./src/Page.js").point
undefined
> require("./src/Page.js").pointToString
undefined
>
I'm at a total loss. 我完全不知所措。 What am I supposed to be doing to get those two functions to export?
我应该怎么做才能导出这两个功能?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.