Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | const EnableLibraryPlugin = require("./library/EnableLibraryPlugin");
|
---|
| 9 |
|
---|
| 10 | /** @typedef {import("../declarations/WebpackOptions").AuxiliaryComment} AuxiliaryComment */
|
---|
| 11 | /** @typedef {import("../declarations/WebpackOptions").LibraryExport} LibraryExport */
|
---|
| 12 | /** @typedef {import("../declarations/WebpackOptions").LibraryName} LibraryName */
|
---|
| 13 | /** @typedef {import("../declarations/WebpackOptions").LibraryType} LibraryType */
|
---|
| 14 | /** @typedef {import("../declarations/WebpackOptions").UmdNamedDefine} UmdNamedDefine */
|
---|
| 15 | /** @typedef {import("./Compiler")} Compiler */
|
---|
| 16 |
|
---|
| 17 | // TODO webpack 6 remove
|
---|
| 18 | class LibraryTemplatePlugin {
|
---|
| 19 | /**
|
---|
| 20 | * @param {LibraryName} name name of library
|
---|
| 21 | * @param {LibraryType} target type of library
|
---|
| 22 | * @param {UmdNamedDefine} umdNamedDefine setting this to true will name the UMD module
|
---|
| 23 | * @param {AuxiliaryComment} auxiliaryComment comment in the UMD wrapper
|
---|
| 24 | * @param {LibraryExport} exportProperty which export should be exposed as library
|
---|
| 25 | */
|
---|
| 26 | constructor(name, target, umdNamedDefine, auxiliaryComment, exportProperty) {
|
---|
| 27 | this.library = {
|
---|
| 28 | type: target || "var",
|
---|
| 29 | name,
|
---|
| 30 | umdNamedDefine,
|
---|
| 31 | auxiliaryComment,
|
---|
| 32 | export: exportProperty
|
---|
| 33 | };
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | /**
|
---|
| 37 | * Apply the plugin
|
---|
| 38 | * @param {Compiler} compiler the compiler instance
|
---|
| 39 | * @returns {void}
|
---|
| 40 | */
|
---|
| 41 | apply(compiler) {
|
---|
| 42 | const { output } = compiler.options;
|
---|
| 43 | output.library = this.library;
|
---|
| 44 | new EnableLibraryPlugin(this.library.type).apply(compiler);
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | module.exports = LibraryTemplatePlugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.