npm esbuild 0.8.19
v0.8.19

latest releases: 0.21.2, 0.21.1, 0.21.0...
3 years ago
  • Handle non-ambiguous multi-path re-exports (#568)

    Wildcard re-exports using the export * from 'path' syntax can potentially result in name collisions that cause an export name to be ambiguous. For example, the following code would result in an ambiguous export if both a.js and b.js export a symbol with the same name:

    export * from './a.js'
    export * from './b.js'

    Ambiguous exports have two consequences. First, any ambiguous names are silently excluded from the set of exported names. If you use an import * as wildcard import, the excluded names will not be present. Second, attempting to explicitly import an ambiguous name using an import {} from import clause will result in a module instantiation error.

    This release fixes a bug where esbuild could in certain cases consider a name ambiguous when it actually isn't. Specifically this happens with longer chains of mixed wildcard and named re-exports. Here is one such case:

    // entry.js
    import {x, y} from './not-ambiguous.js'
    console.log(x, y)
    // /not-ambiguous.js
    export * from './a.js'
    export * from './b.js'
    // /a.js
    export * from './c.js'
    // /b.js
    export {x} from './c.js'
    // /c.js
    export let x = 1, y = 2

    Previously bundling entry.js with esbuild would incorrectly generate an error about an ambiguous x export. Now this case builds successfully without an error.

  • Omit warnings about non-string paths in await import() inside a try block (#574)

    Bundling code that uses require() or import() with a non-string path currently generates a warning, because the target of that import will not be included in the bundle. This is helpful to warn about because other bundlers handle this case differently (e.g. Webpack bundles the entire directory tree and emulates a file system lookup) so existing code may expect the target of the import to be bundled.

    You can avoid the warning with esbuild by surrounding the call to require() with a try block. The thinking is that if there is a surrounding try block, presumably the code is expecting the require() call to possibly fail and is prepared to handle the error. However, there is currently no way to avoid the warning for import() expressions. This release introduces an analogous behavior for import() expressions. You can now avoid the warning with esbuild if you use await import() and surround it with a try block.

Don't miss a new esbuild release

NewReleases is sending notifications on new releases.