From a5f781ecd5edeb3fb6ae8d1045507ab850462614 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Mon, 20 Feb 2023 22:54:40 -0500 Subject: [PATCH] fix #2940: adjust node's values in `compat-table` --- CHANGELOG.md | 13 +++++++++++++ internal/compat/js_table.go | 8 ++++---- scripts/compat-table.js | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5872a311075..95409c77339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## Unreleased + +* Adjust some feature compatibility tables for node ([#2940](https://github.com/evanw/esbuild/issues/2940)) + + This release makes the following adjustments to esbuild's internal feature compatibility tables for node, which tell esbuild which versions of node are known to support all aspects of that feature: + + * `class-private-brand-checks`: node v16.9+ => node v16.4+ (a decrease) + * `hashbang`: node v12.0+ => node v12.5+ (an increase) + * `optional-chain`: node v16.9+ => node v16.1+ (a decrease) + * `template-literal`: node v4+ => node v10+ (an increase) + + Each of these adjustments was identified by comparing against data from the `node-compat-table` package and was manually verified using old node executables downloaded from https://nodejs.org/download/release/. + ## 0.17.10 * Update esbuild's handling of CSS nesting to match the latest specification changes ([#1945](https://github.com/evanw/esbuild/issues/1945)) diff --git a/internal/compat/js_table.go b/internal/compat/js_table.go index e2b5e6040b3..f2bf9c96de0 100644 --- a/internal/compat/js_table.go +++ b/internal/compat/js_table.go @@ -276,7 +276,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{ ES: {{start: v{2022, 0, 0}}}, Firefox: {{start: v{90, 0, 0}}}, IOS: {{start: v{15, 0, 0}}}, - Node: {{start: v{16, 9, 0}}}, + Node: {{start: v{16, 4, 0}}}, Opera: {{start: v{77, 0, 0}}}, Safari: {{start: v{15, 0, 0}}}, }, @@ -459,7 +459,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{ Edge: {{start: v{79, 0, 0}}}, Firefox: {{start: v{67, 0, 0}}}, IOS: {{start: v{13, 4, 0}}}, - Node: {{start: v{12, 0, 0}}}, + Node: {{start: v{12, 5, 0}}}, Opera: {{start: v{62, 0, 0}}}, Safari: {{start: v{13, 1, 0}}}, }, @@ -589,7 +589,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{ ES: {{start: v{2020, 0, 0}}}, Firefox: {{start: v{74, 0, 0}}}, IOS: {{start: v{13, 4, 0}}}, - Node: {{start: v{16, 9, 0}}}, + Node: {{start: v{16, 1, 0}}}, Opera: {{start: v{77, 0, 0}}}, Safari: {{start: v{13, 1, 0}}}, }, @@ -677,7 +677,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{ ES: {{start: v{2015, 0, 0}}}, Firefox: {{start: v{34, 0, 0}}}, IOS: {{start: v{9, 0, 0}}}, - Node: {{start: v{4, 0, 0}}}, + Node: {{start: v{10, 0, 0}}}, Opera: {{start: v{28, 0, 0}}}, Safari: {{start: v{9, 0, 0}}}, }, diff --git a/scripts/compat-table.js b/scripts/compat-table.js index 43d15c5264c..c07969f4372 100644 --- a/scripts/compat-table.js +++ b/scripts/compat-table.js @@ -372,6 +372,21 @@ for (const feature in features) { } } +// Apply some manual overrides from this thread: https://github.com/evanw/esbuild/issues/2940#issuecomment-1437818002 +// Each one has been manually checked using past node releases: https://nodejs.org/download/release/ +applyManualOverride('ClassPrivateBrandCheck', 'node', [{ start: [16, 9], end: null }], [{ start: [16, 4], end: null }]) +applyManualOverride('Hashbang', 'node', [{ start: [12, 0], end: null }], [{ start: [12, 5], end: null }]) +applyManualOverride('OptionalChain', 'node', [{ start: [16, 9], end: null }], [{ start: [16, 1], end: null }]) +applyManualOverride('TemplateLiteral', 'node', [{ start: [4], end: null }], [{ start: [10], end: null }]) + +function applyManualOverride(target, engine, expected, changed) { + const observed = JSON.stringify(versions[target][engine]) + expected = JSON.stringify(expected) + if (observed !== expected) + throw new Error(`Mismatch for versions.${target}.${engine}: Expected ${observed} to be ${expected}`) + versions[target][engine] = changed +} + function upper(text) { if (text === 'es' || text === 'ios' || text === 'ie') return text.toUpperCase() return text[0].toUpperCase() + text.slice(1)