"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

const {
  Template
} = require('webpack');

const pluginName = 'RequireVariablePublicPlugin';

class RequireVariablePublicPlugin {
  constructor(options) {
    this.requireFuncName = options.requireFuncName;
  }

  apply(compiler) {
    compiler.hooks.thisCompilation.tap(pluginName, ({
      mainTemplate
    }) => {
      mainTemplate.hooks.requireExtensions.tap(pluginName, source => Template.asString([source, '', `window[${JSON.stringify(this.requireFuncName)}] = ${mainTemplate.requireFn};`]));
    });
  }

}

var _default = RequireVariablePublicPlugin;
exports.default = _default;