Rollup: Bundle in-memory files with JS API

Created on 5 Oct 2016  ·  3Comments  ·  Source: rollup/rollup

Hi there! First of all, thanks a lot for your work. Rollup looks really interesting and a true contender in the JS bundler competition.

I'm the author of Fable an F# to JS compiler. Fable translates F# files to AST objects understandable by Babel and then calls Babel API to generate JS code from these objects that can be printed to output files. After that, developers can use any tool (Rollup, Webpack, Browserify...) to bundle the files if needed.

However, I got some requests to skip the file printing step and emit directly the bundled file. I've investigated Webpack and Browserify and, while they make possible to write a plugin/loader that loads code from memory, the problem is they always work on a per file basis, while Fable/F# works on a project-basis so I need to be able to bundle several files at once.

I had a brief look at Rollup JS API documentation and source and it looks like it understands AST objects (same spec as Babel?) and it could be possible to bundle files or AST objects directly from memory. But the API still requires a physical file path as a entry point. Would it be difficult to pass an in-memory dictionary of filenames and contents (also indicating which one is the entry point) instead? Maybe it's something I could work on if you agree and offer some guidance.

Cheers!

c⁵ ⋅ question

Most helpful comment

@alfonsogarciacaro Fable looks great by the way. :+1:

All 3 comments

@alfonsogarciacaro Take a look at rollup-plugin-hypothetical. It allows you to create an in-memory file system with source map support and might work well for you.

@Victorystick That looks like it can solve my problem! I'll definitely have a look, thanks a lot for the quick answer!

Closing the issue for now, I'll reopen again if I have follow-up questions.

Thanks again!

@alfonsogarciacaro Fable looks great by the way. :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alendit picture alendit  ·  3Comments

Announcement picture Announcement  ·  3Comments

azdavis picture azdavis  ·  3Comments

adammockor picture adammockor  ·  3Comments

jodarove picture jodarove  ·  3Comments