* Adds the provided object to the compilation. * @param {object} options options * @param {string} options.context context string path * @param {Dependency} options.dependency dependency used to create Module chain * @param {Partial<ModuleFactoryCreateDataContextInfo>=} options.contextInfo a
({ context, dependency, contextInfo }, callback)
| 2611 | * @returns {void} will throw if dependency instance is not a valid Dependency |
| 2612 | */ |
| 2613 | addModuleTree({ context, dependency, contextInfo }, callback) { |
| 2614 | if ( |
| 2615 | typeof dependency !== "object" || |
| 2616 | dependency === null || |
| 2617 | !dependency.constructor |
| 2618 | ) { |
| 2619 | return callback( |
| 2620 | new WebpackError("Parameter 'dependency' must be a Dependency") |
| 2621 | ); |
| 2622 | } |
| 2623 | const Dep = |
| 2624 | /** @type {DependencyConstructor} */ |
| 2625 | (dependency.constructor); |
| 2626 | const moduleFactory = this.dependencyFactories.get(Dep); |
| 2627 | if (!moduleFactory) { |
| 2628 | return callback( |
| 2629 | new WebpackError( |
| 2630 | `No dependency factory available for this dependency type: ${dependency.constructor.name}` |
| 2631 | ) |
| 2632 | ); |
| 2633 | } |
| 2634 | |
| 2635 | this.handleModuleCreation( |
| 2636 | { |
| 2637 | factory: moduleFactory, |
| 2638 | dependencies: [dependency], |
| 2639 | originModule: null, |
| 2640 | contextInfo, |
| 2641 | context |
| 2642 | }, |
| 2643 | (err, result) => { |
| 2644 | if (err && this.bail) { |
| 2645 | callback(err); |
| 2646 | this.buildQueue.stop(); |
| 2647 | this.rebuildQueue.stop(); |
| 2648 | this.processDependenciesQueue.stop(); |
| 2649 | this.factorizeQueue.stop(); |
| 2650 | } else if (!err && result) { |
| 2651 | callback(null, result); |
| 2652 | } else { |
| 2653 | callback(); |
| 2654 | } |
| 2655 | } |
| 2656 | ); |
| 2657 | } |
| 2658 | |
| 2659 | /** |
| 2660 | * Adds the provided string to the compilation. |
no test coverage detected