* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}
(compiler)
| 37 | * @returns {void} |
| 38 | */ |
| 39 | apply(compiler) { |
| 40 | compiler.hooks.validate.tap(PLUGIN_NAME, () => { |
| 41 | compiler.validate( |
| 42 | () => require(class="st">"../../schemas/plugins/container/ContainerPlugin.json"), |
| 43 | this.options, |
| 44 | { |
| 45 | name: class="st">"Container Plugin", |
| 46 | baseDataPath: class="st">"options" |
| 47 | }, |
| 48 | (options) => |
| 49 | require(class="st">"../../schemas/plugins/container/ContainerPlugin.check")( |
| 50 | options |
| 51 | ) |
| 52 | ); |
| 53 | }); |
| 54 | |
| 55 | const library = this.options.library || { |
| 56 | type: class="st">"var", |
| 57 | name: this.options.name |
| 58 | }; |
| 59 | |
| 60 | if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) { |
| 61 | compiler.options.output.enabledLibraryTypes.push(library.type); |
| 62 | } |
| 63 | |
| 64 | const exposes = /** @type {ExposesList} */ ( |
| 65 | parseOptions( |
| 66 | this.options.exposes, |
| 67 | (item) => ({ |
| 68 | import: Array.isArray(item) ? item : [item], |
| 69 | name: undefined |
| 70 | }), |
| 71 | (item) => ({ |
| 72 | import: Array.isArray(item.import) ? item.import : [item.import], |
| 73 | name: item.name || undefined |
| 74 | }) |
| 75 | ) |
| 76 | ); |
| 77 | |
| 78 | const shareScope = this.options.shareScope || class="st">"default"; |
| 79 | |
| 80 | compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => { |
| 81 | const hooks = |
| 82 | getModuleFederationPlugin().getCompilationHooks(compilation); |
| 83 | const dep = new ContainerEntryDependency( |
| 84 | this.options.name, |
| 85 | exposes, |
| 86 | shareScope |
| 87 | ); |
| 88 | dep.loc = { name: this.options.name }; |
| 89 | compilation.addEntry( |
| 90 | compilation.options.context, |
| 91 | dep, |
| 92 | { |
| 93 | name: this.options.name, |
| 94 | filename: this.options.filename, |
| 95 | runtime: this.options.runtime, |
| 96 | library |
nothing calls this directly
no test coverage detected