You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 14:15:13