如何在ESM中导出含连字符命名的变量?(适配Firebase Functions v2)
CommonJS (CJS)
exports['foo-bar'] = {} // -> OK
ECMAScript Modules (ESM)
exports['foo-bar'] = {}; // -> NG export['foo-bar'] = {}; // -> NG export { 'foo-bar': {} }; // -> NG export { fooBar as foo-bar }; // -> NG export { fooBar as 'foo-bar' }; // -> NG
通常我不会这么做,原本也不会有问题,但由于Firebase Functions v2仅允许函数名称使用小写字母、数字和连字符且要求必须导出这类命名的变量,因此我遇到了困难。
内容的提问来源于stack exchange,提问作者minodisk
相关产品推荐
相关产品推荐

