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

Separate the concept of a plugin from the concept of a file transformation. #64

Closed
AriaFallah opened this issue Jul 30, 2016 · 2 comments

Comments

@AriaFallah
Copy link

AriaFallah commented Jul 30, 2016

Why

As per my comment here #62 (comment), I think the separate concepts of a plugin and a transform are conflated, and pundle can benefit by making the concepts distinct.

  • It would make pundle easier to understand in my opinion since it'd map 1-to-1 with the concept of Extract-Tranform-Load.
    • Extract = require()
    • Transform = transforms/transformer <- new addition to replace plugin
    • Load = loaders
  • This frees up the word plugin to mean side-effects of the ETL process.
    • An eslint plugin to log errors
    • A plugin to install npm packages if they're found in the code.
    • Anything else someone wants to do by hooking into pundle
  • In my experience / in my opinion, separating impure/pure code makes it easier to maintain pundle, and it would make it easier for users to see where their problems are occurring.

How

Add a new loadTransformers() function that puts each of the transformers into an array called this.transformers or something like that. The after the line here where you emit the before-process event do something like

let result = event.contents
for (const transformer of this.transformers) {
  result = transformer(this, filePath, result, event.sourceMap)
}
result = loader(this, filePath, event.contents, event.sourceMap)

Thoughts?

@steelbrain
Copy link
Owner

steelbrain commented Jul 30, 2016

I'm in favor of separating plugins and transformers. We would ideally have just one .load() that accepts both Plugins and Transformers.

It should be done with the change mentioned in #61 (comment)

I'll post an update after I figure out a realistic API or the flaws in the one discussed

@steelbrain
Copy link
Owner

Fixed in Pundle v2Alpha1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants