Replies: 7 comments 7 replies
-
Plugins could be made using callbacks similar to Laravel's middleware https://laravel.com/docs/8.x/middleware#defining-middleware. type data = {};
type next = (data: data) => data;
type config = {};
// Example struc
abstract class RomePlugin {
// Whatever the name of the stages would be
abstract compile(data: data, next: next, config: config): data;
abstract bundle(data: data, next: next, config: config): data;
}
class pluginA extends RomePlugin {
compile(data: data, next: next, config: config): data {
data.doStuff();
// Returning `data` instead of `next` would not run the other plugins
return next(data);
}
bundle(data: data, next: next, config: config): data {
// Using the return value of the closure would run all the other plugins before performing it's actions
let processedData = next(data);
processedData.doOtherStuff();
return processedData;
}
}
class pluginB extends RomePlugin {
...
}
// config plugin list, would run in order for each stage
plugins: [
pluginB,
pluginA,
] This would also make the backend implementation fairly easy. This should in theory be working const config;
// Repeat for each stage
function runCompile() {
// Internal compiling code
const internalData = internalFunction();
let i = 0;
const next = (data: data): data => {
if (i >= config.plugins.length) return data;
const plugin = config.plugins[i++];
return new plugin().compile(data, next, config);
}
return next(internalData); // Fully compiled code
} |
Beta Was this translation helpful? Give feedback.
-
I think the philosophy of the bundler should reflect what the modern web development needs. We need a bundler for when we ship code to production (still) but we don't need a bundler for develop our applications locally. That's where snowpack and vite shine. I believe Rome should follow the same philosophy. ESM modules for web development, optimized build for production. That being said, about the plugin system, I think the concept of "plugin" is too broad and it's really difficult to understand what a plugin does. I like Parcel's approach, where they have specific naming convention that helps to understand the responsibility of a "plugin". They have transformers, optimizers, packagers, etc. and they are divided by file extension. What do you think? |
Beta Was this translation helpful? Give feedback.
-
ESM modules for development and optimized builds for prod sound like the way to go. Had a quick look to Parcel's plugin system, really like the idea of auto loading & splitting them. @sebmck any takes on this? |
Beta Was this translation helpful? Give feedback.
-
When bundling rome checks all files included in the bundle, we should maybe disable some checks for node_modules packages. |
Beta Was this translation helpful? Give feedback.
-
@jer3m01 We actually already have an |
Beta Was this translation helpful? Give feedback.
-
Are there any plans to make sure bundling is performant? It seems like WASM powered tools like Just curious what kind of optimizations and performance tweaks would be needed to make this relatively fast |
Beta Was this translation helpful? Give feedback.
-
Here are some of my personal thoughts on plugins. Some of these are longer-term goals but would inform earlier decisions if we decided to pursue them. A typical user should be able to use plugins without editing (or even reading) any configuration files. We should have a powerful Plugins can contribute multiple different capabilities (lint rules, compiler transforms, etc) and they declare that in a manifest. Some sort of Plugins aren’t required to be dedicated packages. If you maintain a package and you want to create some related rome lint rules, it should be possible to just add those capabilities to your existing package and tell your users what No naming conventions, not even a |
Beta Was this translation helpful? Give feedback.
-
Used to track discussion related to the rome bundler and the design of it's plugin system.
Beta Was this translation helpful? Give feedback.
All reactions