Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tapable.plugin is deprecated. Use new API on .hooks instead #83

Open
adityashukla74 opened this issue Oct 15, 2020 · 0 comments
Open

Tapable.plugin is deprecated. Use new API on .hooks instead #83

adityashukla74 opened this issue Oct 15, 2020 · 0 comments

Comments

@adityashukla74
Copy link

I am trying to upgrade my Webpack 4 to Webpack5. (Earlier it was Webpack2)

On running node --trace-deprecation node_modules/webpack/bin/webpack.js
I get

**(node:30954) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead
at DecompressPlugin.apply (/Users/adityashukla/projects/userInterface/source-catalog-web/plugins/DecompressPlugin.js:16:18)
at webpack (/Users/adityashukla/projects/userInterface/source-catalog-web/node_modules/webpack/lib/webpack.js:51:13)
**

My Plugin looks like this

const path = require('path'),
const path = require('path'),
    decompress = require('decompress'),
    crypto = require('crypto'),
    glob = require('glob');

class DecompressPlugin {
    constructor(dist) {
        if (!dist) {
            throw new Error('dist is a required option');
        }

        this.dist = dist;
    }

    apply(compiler) {
        compiler.plugin('emit', (compilation, done) => {
            const files = glob.sync('**/*.decompress.tar.bz2', {'cwd': 'src'}),
                hash = crypto.createHash('sha256').update(JSON.stringify(files.sort()), 'utf8').digest('hex');

            if (this.hash !== hash) {
                this.hash = hash;

                files.forEach((f) => {
                    const folder = path.dirname(f).split(path.sep),
                        parts = [this.dist].concat(folder.slice(1)),
                        destination = parts.join(path.sep);

                    decompress(path.join('src', f), destination).then(() => {
                        done();
                    });
                });
            } else {
                done();
            }
        });
    }
}

module.exports = DecompressPlugin;

How can i resolve this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant