esbuild 0.12.7
-
Quote object properties that are modern Unicode identifiers (#1349)
In ES6 and above, an identifier is a character sequence starting with a character in the
ID_StartUnicode category and followed by zero or more characters in theID_ContinueUnicode category, and these categories must be drawn from Unicode version 5.1 or above.But in ES5, an identifier is a character sequence starting with a character in one of the
Lu, Ll, Lt, Lm, Lo, NlUnicode categories and followed by zero or more characters in theLu, Ll, Lt, Lm, Lo, Nl, Mn, Mc, Nd, PcUnicode categories, and these categories must be drawn from Unicode version 3.0 or above.Previously esbuild always used the ES6+ identifier validation test when deciding whether to use an identifier or a quoted string to encode an object property but with this release, it will use the ES5 validation test instead:
// Original code x.ꓷꓶꓲꓵꓭꓢꓱ = { ꓷꓶꓲꓵꓭꓢꓱ: y }; // Old output x.ꓷꓶꓲꓵꓭꓢꓱ = { ꓷꓶꓲꓵꓭꓢꓱ: y }; // New output x["ꓷꓶꓲꓵꓭꓢꓱ"] = { "ꓷꓶꓲꓵꓭꓢꓱ": y };This approach should ensure maximum compatibility with all JavaScript environments that support ES5 and above. Note that this means minified files containing Unicode properties may be slightly larger than before.
-
Ignore
tsconfig.jsonfiles insidenode_modules(#1355)Package authors often publish their
tsconfig.jsonfiles to npm because of npm's default-include publishing model and because these authors probably don't know about.npmignorefiles. People trying to use these packages with esbuild have historically complained that esbuild is respectingtsconfig.jsonin these cases. The assumption is that the package author published these files by accident.With this release, esbuild will no longer respect
tsconfig.jsonfiles when the source file is inside anode_modulesfolder. Note thattsconfig.jsonfiles insidenode_modulesare still parsed, and extendingtsconfig.jsonfiles from inside a package is still supported. -
Fix missing
--metafilewhen using--watch(#1357)Due to an oversight, the
--metafilesetting didn't work when--watchwas also specified. This only affected the command-line interface. With this release, the--metafilesetting should now work in this case. -
Add a hidden
__esModuleproperty to modules in ESM format (#1338)Module namespace objects from ESM files will now have a hidden
__esModuleproperty. This improves compatibility with code that has been converted from ESM syntax to CommonJS by Babel or TypeScript. For example:// Input TypeScript code import x from "y" console.log(x) // Output JavaScript code from the TypeScript compiler var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const y_1 = __importDefault(require("y")); console.log(y_1.default);If the object returned by
require("y")doesn't have an__esModuleproperty, theny_1will be the object{ "default": require("y") }. If the file"y"is in ESM format and has a default export of, say, the valuenull, that meansy_1will now be{ "default": { "default": null } }and you will need to usey_1.default.defaultto access the default value. Adding an automatically-generated__esModuleproperty when converting files in ESM format to CommonJS is required to make this code work correctly (i.e. for the value to be accessible via justy_1.defaultinstead).With this release, code in ESM format will now have an automatically-generated
__esModuleproperty to satisfy this convention. The property is non-enumerable so it shouldn't show up when iterating over the properties of the object. As a result, the export name__esModuleis now reserved for use with esbuild. It's now an error to create an export with the name__esModule.This fix was contributed by @lbwa.