-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom paths for entrypoints, chunks, and assets in outdir #224
Comments
Just adding my support for having this feature. I, too, cannot do a full build because the entry files are all lumped in the I don't mind, because I can still do a full release build with Rollup and use esbuild for all my testing, but it would be great to have this feature. |
Spent a good while today playing with the esbuild JS API, hoping to maybe emulate this feature via Transform, but I just don't think it's possible. I don't need to be able to configure the output chunks, I just need them to mirror the structure of the input entry files. Fingers crossed this lands in a forth-coming release :) |
(Merging in from #244) Problem Given the following file structure:
If you run:
You get the following error:
Possible Solution I think I'd expect the bundle output to look like this:
So it seems like there'd need to be a base directory (defaulting to working directory) so you could do: const rel = path.relative(basedir, entry)
const outpath = path.join(outdir, rel) I'd suggest steering this discussion to the minimal changes required to solve this problem. I agree that customizing the names of chunks, assets, and entrypoints is nice to have (I use these features in rollup too), but even without any of those options, rollup and tsc handle the issue of two entrypoints in different directories with the same name. |
Just did a survey of different tools to see what they do. It looks like Parcel and tsc avoid collisions by generating nested folders (so Rollup avoids collisions by adding a number after the file (so |
This should be fixed as of version 0.6.0. |
Superb, thank you! I will test this on my codebase on Monday and open an issue if I find any. It should be a good test, as there are over 1200 entry points for the API (which is why I'm desperate to move away from Rollup as it takes over 6mins for a full build) |
Works beautifully. Thanks Evan! Entrypoints
Additional Chunks
|
How long does it take now? Just curious.
Thanks for reporting back. That's great to hear! |
@evanw thought you may like to know that I finished migrating my build scripts over from Rollup to esbuild (I had to code my own functions for things like clearing dist folder, copying files, etc but this is trivial in node.js). Here is the build log now:
Just to be clear, it used to take Rollup over 6 minutes to do the exact same thing. The esbuild portion of this log is just 21 ms for, currently, 1,151 entry points. Lovely :) |
Is there a way to "turn this feature off" and have esbuild put all files in the same folder? |
I'd like this too. One of my entrypoints is a dynamic temporary file, while the others may be just in the source directory. This leads to a path for the temp file output starting with a bunch of directories called |
Answering my own comment: when using the object form for entryPoints: {
main: '/tmp/djjd73e.js',
other: '/home/me/proj/lib/x.js'
} |
Any updates on this? I want to bundle my code for a Shopify theme however as their guidelines define themes aren't currently allowed to have nested directories (but only one single |
@loicnestler lol - same |
For anyone still struggling with this problem:
import { parse } from 'path'
// Load all the files
const filePaths = glob.sync('src/**/*.ts')
// Transform into a map of name => path
const mapped = new Map(filePaths.map(path => [
parse(path).name,
path
]))
const entryPoints = Object.fromEntries(mapped)
// Esbuild will output all files flat into the outdir
build({
entryPoints,
// ...,
outdir: 'assets/'
}) |
I have been unable to build my project with esbuild because the structure of the output directory is not customizable. For example, esbuild fails for multiple entrypoints with the same basename, such as
src/a/page.tsx
andsrc/b/page.tsx
, because esbuild wants to output both to<outdir>/page.js
. Rollup'sinput
,entryFileNames
,chunkFileNames
, andassetFileNames
options give users a good deal of control over where output files are placed. Would you consider similar features for esbuild?Perhaps something like this...
...which would output
dist/pages/pageA.js
anddist/pages/pageB.js
.Below are links to Rollup's documentation for the relevant options:
http://rollupjs.org/guide/en/#input
http://rollupjs.org/guide/en/#outputentryfilenames
http://rollupjs.org/guide/en/#outputchunkfilenames
http://rollupjs.org/guide/en/#outputassetfilenames
The text was updated successfully, but these errors were encountered: