diff --git a/src/index.ts b/src/index.ts index 1fc9e08..9e419ad 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,10 @@ import * as path from 'path'; - 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(); @@ -166,4 +165,4 @@ interface FsStats { isFile(): boolean; isDirectory(): boolean; size: number; -} \ No newline at end of file +} diff --git a/test/index.spec.js b/test/index.spec.js index 9613cff..f16281c 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -40,10 +40,10 @@ describe('plugin', () => { const plugin = new Plugin({ collections: 'node_modules/tool-components/toolcomponents' }); - sinon.spy(mockCompiler, 'plugin'); + 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(mockCompiler.hooks.emit.tapAsync.calledOnce).to.be.true; + expect(mockCompiler.hooks.emit.tapAsync.calledWith('StencilPlugin')).to.be.true; }); }); diff --git a/test/mock-compiler.js b/test/mock-compiler.js index b47fc87..e78f8cb 100644 --- a/test/mock-compiler.js +++ b/test/mock-compiler.js @@ -1,3 +1,7 @@ module.exports = class { - plugin() {} + hooks = { + emit: { + tapAsync(){} + } + } }