diff --git a/lib/serialize/globals.js b/lib/serialize/globals.js index 0e92295d..c781ca60 100644 --- a/lib/serialize/globals.js +++ b/lib/serialize/globals.js @@ -18,12 +18,8 @@ const {createDependency} = require('./records.js'), {GLOBAL, MODULE, VALUE, GETTER, SETTER, PROTO, EVAL, COMMON_JS} = require('../shared/constants.js'), {isJsIdentifier, firstMapKey} = require('./utils.js'), { - GLOBAL_TOP_LEVEL_TYPE, - GLOBAL_MODULE_TYPE, - GLOBAL_PROPERTY_TYPE, - GLOBAL_PROTOTYPE_TYPE, - GLOBAL_GETTER_SETTER_TYPE, - registerSerializer + GLOBAL_TOP_LEVEL_TYPE, GLOBAL_MODULE_TYPE, GLOBAL_PROPERTY_TYPE, GLOBAL_PROTOTYPE_TYPE, + GLOBAL_GETTER_SETTER_TYPE, GLOBAL_MINUS_INFINITY_TYPE, registerSerializer } = require('./types.js'); // Exports @@ -119,13 +115,10 @@ function traceGlobal({type, parent, key}, record) { } // Special values - // TODO: Remove this - can be a primitive - /* if (key === 'minusInfinity') { - createDependency(record, this.traceValue(Infinity)); + this.traceDependency(Infinity, undefined, undefined, record); return GLOBAL_MINUS_INFINITY_TYPE; } - */ // TODO: Add other special values throw new Error('Special types not supported'); @@ -233,13 +226,11 @@ registerSerializer(GLOBAL_GETTER_SETTER_TYPE, serializeGlobalGetterSetter); * @param {Object} record - Record * @returns {Object} - AST node */ -// TODO: Remove this - can be a primitive -/* function serializeMinusInfinity(record) { const infinityNode = this.serializeValue(firstMapKey(record.dependencies)); return t.unaryExpression('-', infinityNode); } -*/ +registerSerializer(GLOBAL_MINUS_INFINITY_TYPE, serializeMinusInfinity); /** * Create member AST node. diff --git a/lib/serialize/types.js b/lib/serialize/types.js index baa9d664..a80d19da 100644 --- a/lib/serialize/types.js +++ b/lib/serialize/types.js @@ -25,6 +25,7 @@ const NO_TYPE = 0, GLOBAL_PROPERTY_TYPE = GLOBAL_TYPE | 2, GLOBAL_PROTOTYPE_TYPE = GLOBAL_TYPE | 3, GLOBAL_GETTER_SETTER_TYPE = GLOBAL_TYPE | 4, + GLOBAL_MINUS_INFINITY_TYPE = GLOBAL_TYPE | 5, EXPORT_JS_TYPE = 1, EXPORT_COMMONJS_TYPE = 2, EXPORT_ESM_TYPE = 3, @@ -51,6 +52,7 @@ module.exports = { GLOBAL_PROPERTY_TYPE, GLOBAL_PROTOTYPE_TYPE, GLOBAL_GETTER_SETTER_TYPE, + GLOBAL_MINUS_INFINITY_TYPE, EXPORT_JS_TYPE, EXPORT_COMMONJS_TYPE, EXPORT_ESM_TYPE,