What is the correct way to export a constant in ES6?

后端 未结 3 1070
有刺的猬
有刺的猬 2021-01-17 08:46

I\'m trying to break my entry file into components but I\'m not sure how to make the constant available to the import. This is what I\'ve tried so far and both seem to work:

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 09:03

    export const ConnectedRange = connectRange(Range);

    Is the ES modules syntax.

    exports.ConnectedRange = connectRange(Range);

    Is the commonJS syntax.

    I would recommend using the ES modules syntax, and compiling to common JS if the environment you run your code on does not support ES modules.

提交回复
热议问题