devolution icon indicating copy to clipboard operation
devolution copied to clipboard

Suggestion: a Webpack Plugin

Open developit opened this issue 5 years ago • 4 comments

I wonder if it would be possible to run this against Webpack's generated .assets (once webpack has generated the modern bundles) rather than actual files on disk? That would keep everything in-memory and also provide a convenient place to kick off devolution for those who are controlling everything else with Webpack already.

developit avatar Jan 07 '20 22:01 developit

Good idea 👍

It might as well provide more information how bundles are connected to each other, and simplify the configuration - right now are you "expected" to provide rootBundle regex, which is not quote convenient and flexible.


Not sure that keeping everything "in memory" is actually required - the process is more CPU bound, and reading even a few megabytes should not be a problem. Also not sure that devolution would play well as a part of webpack configuration, as long as it's expected to be the last step, producing more than one result, and thus confusing any other plugin which might run after it. And, to be honest, this moment is worrying me a bit - it is a guarantee that devolution would not work with anything like itself. Like per-language bundle separation for example.

theKashey avatar Jan 08 '20 00:01 theKashey

Hmm - I don't think the plugin interoperability would be an issue here, since devolution would be running at the last stage of compilation long after everything has been converted to JavaScript. The in-memory thing is more of a constraint - there's a bunch of cases where Webpack isn't emitting files on disk, so plugins generally have to avoid relying on them. Even if it doesn't help for performance, it would make things like html-webpack-plugin able to see the generated downleveled JS assets.

FWIW, I might be able to spend some time prototyping this if there's interest. I haven't looked into how difficult it would be to actually wire things up to devolution in its current state, but I'm generally interested in seeing the approach catch on. I've been pushing on this concept (treating ecmascript version downleveling as a postprocessing step) in a few different places and would love to have an open source implementation of it!

developit avatar Jan 08 '20 15:01 developit

html-webpack-plugin sounds like a good reason, however devolution was made to "work" on a publicUrl level, "cloning" dist directory as-is, so the customer don't have to think how to get files, and which files - hashes in the filenames, structure, and like everything else would be the same - just change publicPath in case of webpack, or import file from the correct location in case of parcel.

I know how much you did for "the approach", and right now is a happy user of preset-modules, providing still required polyfills via devolution. I'm interested in making it more correct, efficient or just easier to use. Please go on 👍

theKashey avatar Jan 08 '20 21:01 theKashey

Alright. I will keep you posted.

developit avatar Jan 12 '20 19:01 developit