Skip to content

Output multiple files when bundle: false #944

Open
@jridgewell

Description

TLDR: When using the JS API and setting bundle: false and write: false, it'd be nice for the result to include multiple output files for each file in the module tree.

This is a bit specific, but one of my biggest goals for my test suite treat each file as an independent module and not bundle them into a large single build file. AMP's current test suite generates a file at about 60mb, and trying to debug that in Chrome is a nuisance (extremely slow to load files in sources pane, and sourcemaps make it even slower). Having each file be independent an module served by the test server would eliminate this pain, and would make incremental building of the test suite extremely fast (just update a relatively small file, instead of concatting the 60mb file together again).

This would be really simple if everything just used ESM. But we still require CJS node modules, and so we still need some sort of transpilation layer to build. Additionally, we use Babel to do a few custom things, so we're definitely stuck with running some transpiler.

Currently, setting bundle: false means that each entry point is considered an independent module, which is good. But it doesn't allow us to generate a metadata for the full dependency tree, and it doesn't continue non-bundling any dependencies of the entry point. What I would like to happen is for esbuild to traverse down the tree and generate output files for each dependency (don't bundle them into a single output). This would allow us to transpile the CJS into ESM using esbuild, and hook into the plugin API to feed into babel for our custom transforms.

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