Skip to content
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

A way to get individual chunks #2086

Closed
nujarum opened this issue Mar 7, 2022 · 2 comments
Closed

A way to get individual chunks #2086

nujarum opened this issue Mar 7, 2022 · 2 comments

Comments

@nujarum
Copy link

nujarum commented Mar 7, 2022

This is a question or maybe a feature request about the bundle option of the Build API.

Is there any way to get the individual chunks to be bundled?

The outputs.inputs[<path>].bytesInOutput in the result.metafile seems to give us the byte length of the chunks, but it seems difficult to split them exactly because the starting position is unclear.

So, is it possible to return information like startInOutput in addition to bytesInOutput?

Or, if you have an alternative, I would be happy to hear about it.

Example of metafile:

{
  inputs: { ... },
  outputs: {
    ...,
    'dist/index.js': {
      ...,
      entryPoint: 'src/index.ts',
      inputs: {
        'src/lib1.ts': { bytesInOutput: 84 },
        'src/index.ts': { bytesInOutput: 0 },
        'src/lib2.ts': { bytesInOutput: 152 } // <-- How can I identify the starting byte position?
      },
    }
  }
}
@evanw
Copy link
Owner

evanw commented Mar 7, 2022

It's not that straightforward because files may be discontiguous in the output file (i.e. in multiple places). You can reconstruct some of this information using source maps, although it depends on what you're looking for. What are you trying to do?

@nujarum
Copy link
Author

nujarum commented Mar 8, 2022

Thanks for your reply, @evanw.

I see, one source file may be output to multiple locations in some cases.

I was looking into the possibility of creating a tool or plugin that could take advantage of esbuild's great transformations, but allow for a little more flexibility in customizing the bundling.

Of course, I recognize that the Transform API can be used to get individual outputs.
However, Cross-module inlining of TypeScript enum only works when bundle is enabled, so I was hoping to use the output from the Build API if possible.

Now that I understand my question, I will close this isssue after a while.

@nujarum nujarum closed this as completed Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants