title: Webpack Obfuscator Issue: Cannot read property 'tap' of undefined
body: <p>I need help with obfuscating my typescript code. I'm using this Electron template though the issue seems particular to webpack and the obfuscator.</p>
  <p><a href="https://github.com/codesbiome/electron-react-webpack-typescript-2021" rel="nofollow noreferrer">https://github.com/codesbiome/electron-react-webpack-typescript-2021</a></p>
  <p>I'm using the following versions:</p>
  <pre><code>&quot;webpack&quot;: &quot;4.46.0&quot;,
  &quot;webpack-obfuscator&quot;: &quot;^3.3.0&quot;
  </code></pre>
  <p>My configurations are:</p>
  <p><strong>webpack.main.js</strong></p>
  <pre><code>module.exports = {
    /**
     * This is the main entry point for your application, it's the first file
     * that runs in the main process.
     */
    entry: ['./src/main.ts'],
    // Put your normal webpack config below here
    module: {
      rules: require('./webpack.rules'),
    },
    resolve: {
      extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
      alias: require('./webpack.aliases'),
    },
  };
  </code></pre>
  <p><strong>webpack.rules.js</strong></p>
  <pre><code>const { inDev } = require('./webpack.helpers');
  const path = require('path');
  const WebpackObfuscator = require('webpack-obfuscator');
  
  module.exports = [
    {
      // Add support for native node modules
      test: /\.node$/,
      use: 'node-loader',
    },
    {
      // Webpack asset relocator loader
      test: /\.(m?js|node)$/,
      parser: { amd: false },
      use: {
        loader: '@marshallofsound/webpack-asset-relocator-loader',
        options: {
          outputAssetBase: 'native_modules',
        },
      },
    },
    {
      // Typescript loader
      test: /\.tsx?$/,
      exclude: /(node_modules|\.webpack)/,
      use: {
        loader: 'ts-loader',
        options: {
          transpileOnly: true,
        },
      },
    },
    {
      // CSS Loader
      test: /\.css$/,
      use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
    },
    {
      // Less loader
      test: /\.less$/,
      use: [
        { loader: 'style-loader' },
        { loader: 'css-loader' },
        { loader: 'less-loader' },
      ],
    },
    {
      // Images Loader
      test: /\.(gif|jpe?g|tiff|png|webp|bmp|svg)$/,
      use: [
        {
          loader: 'file-loader',
          options: {
            publicPath: 'assets/images',
            outputPath: inDev() ? 'assets/images' : './main_window/assets/images',
          },
        },
      ],
    },
    {
      // Font &amp; SVG loader
      test: /\.(woff(2)?|ttf|otf|eot)$/,
      use: [
        {
          loader: 'file-loader',
          options: {
            publicPath: 'assets/fonts',
            outputPath: inDev() ? 'assets/fonts' : './main_window/assets/fonts',
          },
        },
      ],
    },
    {
      test: /\.tsx?$/,
      exclude: /node_modules/,
      enforce: 'post',
      use: {
        loader: WebpackObfuscator.loader,
        options: {
          rotateStringArray: true,
        },
      },
    },
  ];
  </code></pre>
  <p><strong>webpack.plugin.js</strong></p>
  <pre><code>const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
  const WebpackObfuscator = require('webpack-obfuscator');
  
  module.exports = [
    new ForkTsCheckerWebpackPlugin(),
    new WebpackObfuscator(
      {
        rotateStringArray: true,
      },
      ['excluded_bundle_name.js'],
    ),
  ];
  </code></pre>
  <p>The error is:</p>
  <pre><code>An unhandled error has occurred inside Forge:
  Cannot read property 'tap' of undefined
  TypeError: Cannot read property 'tap' of undefined
      at /Users/mt/Desktop/ca/ca-app/node_modules/webpack-obfuscator/dist/plugin/index.js:25:45
      at SyncHook.eval (eval at create (/Users/mt/Desktop/ca/ca-app/node_modules/tapable/lib/HookCodeFactory.js:19:10), &lt;anonymous&gt;:13:1)
      at SyncHook.lazyCompileHook (/Users/mt/Desktop/ca/ca-app/node_modules/tapable/lib/Hook.js:154:20)
      at Compiler.newCompilation (/Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Compiler.js:631:26)
      at /Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Compiler.js:667:29
      at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/mt/Desktop/ca/ca-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), &lt;anonymous&gt;:6:1)
      at AsyncSeriesHook.lazyCompileHook (/Users/mt/Desktop/ca/ca-app/node_modules/tapable/lib/Hook.js:154:20)
      at Compiler.compile (/Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Compiler.js:662:28)
      at /Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Watching.js:77:18
      at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/mt/Desktop/ca/ca-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), &lt;anonymous&gt;:33:1)
      at AsyncSeriesHook.lazyCompileHook (/Users/mt/Desktop/ca/ca-app/node_modules/tapable/lib/Hook.js:154:20)
      at Watching._go (/Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Watching.js:41:32)
      at /Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Watching.js:33:9
      at Compiler.readRecords (/Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Compiler.js:529:11)
      at new Watching (/Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Watching.js:30:17)
      at Compiler.watch (/Users/mt/Desktop/ca/ca-app/node_modules/webpack/lib/Compiler.js:244:10)
  </code></pre>
  <p>Thanks in advance.</p>