From 9f33784350b1efc2e774bbfc087cbd2c47828748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 18 Jul 2020 07:59:03 +0900 Subject: [PATCH] fix: es6 export enum (#1446) Co-authored-by: Alexander Fenster --- cli/targets/static.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/targets/static.js b/cli/targets/static.js index d535e445b..d4a061f6e 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -682,7 +682,10 @@ function buildEnum(ref, enm) { comment.push((config.forceEnumString ? "@property {string} " : "@property {number} ") + key + "=" + val + " " + (enm.comments[key] || key + " value")); }); pushComment(comment); - push(escapeName(ref) + "." + escapeName(enm.name) + " = (function() {"); + if (!ref && config.es6) + push("export const " + escapeName(enm.name) + " = " + escapeName(ref) + "." + escapeName(enm.name) + " = (() => {"); + else + push(escapeName(ref) + "." + escapeName(enm.name) + " = (function() {"); ++indent; push((config.es6 ? "const" : "var") + " valuesById = {}, values = Object.create(valuesById);"); var aliased = [];