Comments (2)
It seems as though the
metafile
is output to the thecwd
and not theoutdir
when specified on the CLI.
The metafile
is written out to the path you provide. All non-absolute paths provided on the command line are relative to the current working directory, as is typical for CLIs.
So I tried just the
esbuild.build
command and that did not work either (so I am thinking that there is some kind of configuration issue I have?).
The documentation for metafile
is here: https://esbuild.github.io/api/#metafile. Note that only the CLI writes it to a file. The JS API esbuild.build
returns it as an in-memory object, as you can see in the code example in the documentation:
import * as esbuild from 'esbuild'
import fs from 'node:fs'
let result = await esbuild.build({
entryPoints: ['app.js'],
bundle: true,
metafile: true,
outfile: 'out.js',
})
fs.writeFileSync('meta.json', JSON.stringify(result.metafile))
Additionally, when using the cli, metafile expects a file name. However, when you use
build
/context
it is just a boolean flag.
If would be great if there was consistency between the API for metafile.
The CLI doesn't return the metafile as an in-memory object because that doesn't make sense for a CLI. The JS API actually used to work as you suggested (taking a file name instead of a boolean flag, and writing it to a file instead of returning it in memory), but in practice this was really annoying to use because you typically need to inspect the metafile object immediately after doing a build call. So the JS API was changed in version 0.9.0 to return it as an in-memory object instead (see #633). This change was intentional.
from esbuild.
Amazing, thank you! That actually makes perfect sense. Only comment would be that that was not immediately clear from the documentation, but a closer inspection of the types would have revealed that.
from esbuild.
Related Issues (20)
- Dynamic import not resolved during build HOT 1
- Static class fields canβt be tree-shaken away on subsequent compilation
- Cloudflare breaks the minimized code for Float's HOT 3
- compilerOptions.paths not resolved when tsconfig extends from another package HOT 1
- ES decorators bug with inheritance and --bundle
- react-compiler support HOT 3
- Question: How did you build a JS/TS parser from scratch? HOT 2
- Empty init functions generated for side-effect-free ESM modules HOT 4
- When transform nullish coalescing it transform != null which may lead to wrong result HOT 3
- [css-minifier]Support CSS Anchor Positioning HOT 2
- Generate TypeScript declarations files for TypeScript projects with isolatedDeclarations enabled
- How can I use 'neutral' platform without getting 'The package "x" wasn't found on the file system but is built into node.' error? HOT 2
- DirectAdmin cannot backup application due to hardlink in esbuild HOT 2
- Import attributes should be enabled for `node18` and >= `node20` targets HOT 2
- Code splitting is creating many small unnecessary chunks HOT 1
- Class missing metadata field in certain cases
- Support for the new "${configDir}" template variable coming in TS v5.5.0 HOT 2
- esbuild tried to read "../../.." , in vite , using npm run dev HOT 1
- Destructuring bug in Safari when renamed parameter property is identical to the function name
- Class binding references in static field initializers should be resolved to the decorated class HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esbuild.