diff --git a/src/index.ts b/src/index.ts index 1fc9e08..4698f5b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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(); diff --git a/test/index.spec.js b/test/index.spec.js index 9613cff..9771042 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -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 }); - }); diff --git a/test/mock-compiler.js b/test/mock-compiler.js index b47fc87..9b42953 100644 --- a/test/mock-compiler.js +++ b/test/mock-compiler.js @@ -1,3 +1,9 @@ -module.exports = class { - plugin() {} +module.exports = function() { + return { + hooks: { + emit: { + tapAsync: () => {} + } + } + } }