Skip to content

Commit

Permalink
Updating plugin to use proper webpack 4 apis
Browse files Browse the repository at this point in the history
  • Loading branch information
stormojm committed Jul 19, 2019
1 parent a5bcadc commit 029b860
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class StencilPlugin {
private fs: FS;

apply(compiler: any) {
compiler.plugin('emit', (compilation: Complication, callback: Function) => {
compiler.hooks.emit.tapAsync('StencilPlugin',
(compilation: Complication, callback: Function) => {
this.fs = compiler.inputFileSystem;
this.inspectModules(compilation.assets, compilation.modules).then(() => {
callback();
Expand Down
6 changes: 2 additions & 4 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ describe('plugin', () => {
const plugin = new Plugin({
collections: 'node_modules/tool-components/toolcomponents'
});
sinon.spy(mockCompiler, 'plugin');
var callback = sinon.spy(mockCompiler.hooks.emit, 'tapAsync');
plugin.apply(mockCompiler);
expect(mockCompiler.plugin.calledOnce).to.be.true;
expect(mockCompiler.plugin.calledWith('emit')).to.be.true;
expect(callback.called).to.true
});

});
10 changes: 8 additions & 2 deletions test/mock-compiler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
module.exports = class {
plugin() {}
module.exports = function() {
return {
hooks: {
emit: {
tapAsync: () => {}
}
}
}
}

0 comments on commit 029b860

Please sign in to comment.