esbuild 0.16.6
-
Do not mark subpath imports as external with
--packages=external(#2741)Node has a feature called subpath imports where special import paths that start with
#are resolved using theimportsfield in thepackage.jsonfile of the enclosing package. The intent of the newly-added--packages=externalsetting is to exclude a package's dependencies from the bundle. Since a package's subpath imports are only accessible within that package, it's wrong for them to be affected by--packages=external. This release changes esbuild so that--packages=externalno longer affects subpath imports. -
Forbid invalid numbers in JSON files
Previously esbuild parsed numbers in JSON files using the same syntax as JavaScript. But starting from this release, esbuild will now parse them with JSON syntax instead. This means the following numbers are no longer allowed by esbuild in JSON files:
- Legacy octal literals (non-zero integers starting with
0) - The
0b,0o, and0xnumeric prefixes - Numbers containing
_such as1_000 - Leading and trailing
.such as0.and.0 - Numbers with a space after the
-such as- 1
- Legacy octal literals (non-zero integers starting with
-
Add external imports to metafile (#905, #1768, #1933, #1939)
External imports now appear in
importsarrays in the metafile (which is present when bundling withmetafile: true) next to normal imports, but additionally haveexternal: trueto set them apart. This applies both to files in theinputssection and theoutputssection. Here's an example:{ "inputs": { "style.css": { "bytes": 83, "imports": [ + { + "path": "https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css", + "kind": "import-rule", + "external": true + } ] }, "app.js": { "bytes": 100, "imports": [ + { + "path": "https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js", + "kind": "import-statement", + "external": true + }, { "path": "style.css", "kind": "import-statement" } ] } }, "outputs": { "out/app.js": { "imports": [ + { + "path": "https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js", + "kind": "require-call", + "external": true + } ], "exports": [], "entryPoint": "app.js", "cssBundle": "out/app.css", "inputs": { "app.js": { "bytesInOutput": 113 }, "style.css": { "bytesInOutput": 0 } }, "bytes": 528 }, "out/app.css": { "imports": [ + { + "path": "https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css", + "kind": "import-rule", + "external": true + } ], "inputs": { "style.css": { "bytesInOutput": 0 } }, "bytes": 100 } } }One additional useful consequence of this is that the
importsarray is now populated when bundling is disabled. So you can now use esbuild with bundling disabled to inspect a file's imports.