Skip to content

Add support for excluding modules from esbuild #5

@alexchandel

Description

@alexchandel

esbuild is following dead code one of my dependencies' dependencies' (batch), and throwing an error when it shouldn't:

> fossilize src/server.js -a assets -a dist -o bin/server.exe

Platforms: win-x64
Cleaning up dist-bin...
Bundling src/server.js...
Resolved Node.js version 'local' to 22.17.1
✘ [ERROR] Could not resolve "emitter"

    node_modules/batch/index.js:9:24:
      9 │   var Emitter = require('emitter');
        ╵                         ~~~~~~~~~

  You can mark the path "emitter" as external to exclude it from the bundle, which will remove this
  error and leave the unresolved path in the bundle. You can also surround this "require" call with
  a try/catch block to handle this failure at run-time instead of bundle-time.

1 error

In context, that line will never execute for Node versions that have events. But esbuild apparently doesn't know that. Normally you'd exclude it from esbuild, but fossilize doesn't forward args or provide any vars to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions