* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}
(compiler)
| 81 | * @returns {void} |
| 82 | */ |
| 83 | apply(compiler) { |
| 84 | const { type, options } = this; |
| 85 | |
| 86 | // Only enable once |
| 87 | const enabled = getEnabledTypes(compiler); |
| 88 | if (enabled.has(type)) return; |
| 89 | enabled.add(type); |
| 90 | |
| 91 | if (typeof options.additionalApply === "function") { |
| 92 | options.additionalApply(); |
| 93 | } |
| 94 | |
| 95 | if (typeof type === "string") { |
| 96 | const enableExportProperty = () => { |
| 97 | const ExportPropertyLibraryPlugin = require("./ExportPropertyLibraryPlugin"); |
| 98 | |
| 99 | new ExportPropertyLibraryPlugin({ |
| 100 | type |
| 101 | }).apply(compiler); |
| 102 | }; |
| 103 | switch (type) { |
| 104 | case "var": { |
| 105 | // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 |
| 106 | const AssignLibraryPlugin = require("./AssignLibraryPlugin"); |
| 107 | |
| 108 | new AssignLibraryPlugin({ |
| 109 | type, |
| 110 | prefix: [], |
| 111 | declare: "var", |
| 112 | unnamed: "error" |
| 113 | }).apply(compiler); |
| 114 | break; |
| 115 | } |
| 116 | case "assign-properties": { |
| 117 | // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 |
| 118 | const AssignLibraryPlugin = require("./AssignLibraryPlugin"); |
| 119 | |
| 120 | new AssignLibraryPlugin({ |
| 121 | type, |
| 122 | prefix: [], |
| 123 | declare: false, |
| 124 | unnamed: "error", |
| 125 | named: "copy" |
| 126 | }).apply(compiler); |
| 127 | break; |
| 128 | } |
| 129 | case "assign": { |
| 130 | // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 |
| 131 | const AssignLibraryPlugin = require("./AssignLibraryPlugin"); |
| 132 | |
| 133 | new AssignLibraryPlugin({ |
| 134 | type, |
| 135 | prefix: [], |
| 136 | declare: false, |
| 137 | unnamed: "error" |
| 138 | }).apply(compiler); |
| 139 | break; |
| 140 | } |
nothing calls this directly
no test coverage detected