Skip to content
This repository has been archived by the owner on Mar 12, 2022. It is now read-only.

fix: update plugin to work with Webpack 5 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions 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();
Expand Down Expand Up @@ -166,4 +165,4 @@ interface FsStats {
isFile(): boolean;
isDirectory(): boolean;
size: number;
}
}
6 changes: 3 additions & 3 deletions test/index.spec.js
Expand Up @@ -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;
});

});
6 changes: 5 additions & 1 deletion test/mock-compiler.js
@@ -1,3 +1,7 @@
module.exports = class {
plugin() {}
hooks = {
emit: {
tapAsync(){}
}
}
}