Created
April 5, 2017 05:31
-
-
Save TheLarkInn/5602da70d184340f7648566c6eb3a054 to your computer and use it in GitHub Desktop.
Notes on functional webpack plugin creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createClass = () => { | |
return class { | |
constructor(options) { this.options = options || {}; } | |
}; | |
} | |
const Plugin = (x) => ( | |
return { | |
map: f => Plugin(f(x)), | |
fold: f => f(x), | |
inspect: () => `Plugin(${x})` | |
}; | |
); | |
const Foo = createClass(); | |
const bar = new Foo(); | |
console.log(bar); | |
// WHAT IT TAKES NOW | |
class SomePlugin { | |
constructor(options) { | |
this.options = options || {}; | |
} | |
apply(compiler) { | |
compiler.plugin("run", (compiler, callback) => { | |
console.log("THE WEBPACK COMPILER JUST STARTED"); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment