Giter VIP home page Giter VIP logo

Comments (1)

hyrious avatar hyrious commented on May 23, 2024

Will it be a compile-time or run-time failure?

Mostly runtime error.

  • __dirname is considered a global variable, like window, which throws a runtime error when it cannot find such reference.
  • import.meta.url is an ESM-only global variable, esbuild will show warnings when bundling to non-ESM formats like CJS or IIFE.
  • fs.readFileSync() means that the dependencies' source may rely on its location in the file system. esbuild can only bundle sources that are referenced by import/requires. So this one will cause related files not being bundled and throws runtime error when there's no such file.
  • .node files are not in esbuild's default loaders list, so esbuild will throw an error of not found loader for such file extension. People may use --loader:.node=file to successfully bundle it.

There're more cases, but one significant knowledge is that esbuild runs static analyzing on the source code. Without actually running the code, esbuild can only bundle "obvious" files that are referenced with each other via import/requires. The "bundle" also does not mean it simulates the whole file system, so any code that depends on a real file system to work will likely to break after bundling.

from esbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.