1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.LicenseWebpackPlugin = void 0;
|
---|
4 | var ChunkIncludeExcludeTester_1 = require("./ChunkIncludeExcludeTester");
|
---|
5 | var PluginChunkReadHandler_1 = require("./PluginChunkReadHandler");
|
---|
6 | var PluginFileHandler_1 = require("./PluginFileHandler");
|
---|
7 | var WebpackFileSystem_1 = require("./WebpackFileSystem");
|
---|
8 | var PluginLicenseTypeIdentifier_1 = require("./PluginLicenseTypeIdentifier");
|
---|
9 | var LicenseTextReader_1 = require("./LicenseTextReader");
|
---|
10 | var WebpackCompilerHandler_1 = require("./WebpackCompilerHandler");
|
---|
11 | var PluginModuleCache_1 = require("./PluginModuleCache");
|
---|
12 | var WebpackAssetManager_1 = require("./WebpackAssetManager");
|
---|
13 | var PluginLicensesRenderer_1 = require("./PluginLicensesRenderer");
|
---|
14 | var PluginLicensePolicy_1 = require("./PluginLicensePolicy");
|
---|
15 | var PluginLicenseTestRunner_1 = require("./PluginLicenseTestRunner");
|
---|
16 | var PluginOptionsReader_1 = require("./PluginOptionsReader");
|
---|
17 | var Logger_1 = require("./Logger");
|
---|
18 | var LicenseWebpackPlugin = /** @class */ (function () {
|
---|
19 | function LicenseWebpackPlugin(pluginOptions) {
|
---|
20 | if (pluginOptions === void 0) { pluginOptions = {}; }
|
---|
21 | this.pluginOptions = pluginOptions;
|
---|
22 | }
|
---|
23 | LicenseWebpackPlugin.prototype.apply = function (compiler) {
|
---|
24 | var fileSystem = new WebpackFileSystem_1.WebpackFileSystem(compiler.inputFileSystem);
|
---|
25 | var optionsReader = new PluginOptionsReader_1.PluginOptionsReader(compiler.context);
|
---|
26 | var options = optionsReader.readOptions(this.pluginOptions);
|
---|
27 | var logger = new Logger_1.Logger(options.stats);
|
---|
28 | var fileHandler = new PluginFileHandler_1.PluginFileHandler(fileSystem, options.buildRoot, options.modulesDirectories, options.excludedPackageTest);
|
---|
29 | var licenseTypeIdentifier = new PluginLicenseTypeIdentifier_1.PluginLicenseTypeIdentifier(logger, options.licenseTypeOverrides, options.preferredLicenseTypes, options.handleLicenseAmbiguity, options.handleMissingLicenseType);
|
---|
30 | var licenseTextReader = new LicenseTextReader_1.LicenseTextReader(logger, fileSystem, options.licenseFileOverrides, options.licenseTextOverrides, options.licenseTemplateDir, options.handleMissingLicenseText);
|
---|
31 | var licenseTestRunner = new PluginLicenseTestRunner_1.PluginLicenseTestRunner(options.licenseInclusionTest);
|
---|
32 | var unacceptableLicenseTestRunner = new PluginLicenseTestRunner_1.PluginLicenseTestRunner(options.unacceptableLicenseTest);
|
---|
33 | var policy = new PluginLicensePolicy_1.PluginLicensePolicy(licenseTestRunner, unacceptableLicenseTestRunner, options.handleUnacceptableLicense, options.handleMissingLicenseText);
|
---|
34 | var readHandler = new PluginChunkReadHandler_1.PluginChunkReadHandler(logger, fileHandler, licenseTypeIdentifier, licenseTextReader, policy, fileSystem);
|
---|
35 | var licenseRenderer = new PluginLicensesRenderer_1.PluginLicensesRenderer(options.renderLicenses, options.renderBanner);
|
---|
36 | var moduleCache = new PluginModuleCache_1.PluginModuleCache();
|
---|
37 | var assetManager = new WebpackAssetManager_1.WebpackAssetManager(options.outputFilename, licenseRenderer);
|
---|
38 | var chunkIncludeExcludeTester = new ChunkIncludeExcludeTester_1.ChunkIncludeExcludeTester(options.chunkIncludeExcludeTest);
|
---|
39 | var handler = new WebpackCompilerHandler_1.WebpackCompilerHandler(chunkIncludeExcludeTester, readHandler, assetManager, moduleCache, options.addBanner, options.perChunkOutput, options.additionalChunkModules, options.additionalModules, options.skipChildCompilers);
|
---|
40 | handler.handleCompiler(compiler);
|
---|
41 | };
|
---|
42 | return LicenseWebpackPlugin;
|
---|
43 | }());
|
---|
44 | exports.LicenseWebpackPlugin = LicenseWebpackPlugin;
|
---|