123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- "use strict";
- class Generator {
-
- static byType(map) {
- return new ByTypeGenerator(map);
- }
-
-
- getTypes(module) {
- const AbstractMethodError = require("./AbstractMethodError");
- throw new AbstractMethodError();
- }
-
-
- getSize(module, type) {
- const AbstractMethodError = require("./AbstractMethodError");
- throw new AbstractMethodError();
- }
-
-
- generate(
- module,
- { dependencyTemplates, runtimeTemplate, moduleGraph, type }
- ) {
- const AbstractMethodError = require("./AbstractMethodError");
- throw new AbstractMethodError();
- }
-
- getConcatenationBailoutReason(module, context) {
- return `Module Concatenation is not implemented for ${this.constructor.name}`;
- }
-
- updateHash(hash, { module, runtime }) {
-
- }
- }
- class ByTypeGenerator extends Generator {
-
- constructor(map) {
- super();
- this.map = map;
- this._types = new Set(Object.keys(map));
- }
-
- getTypes(module) {
- return this._types;
- }
-
- getSize(module, type) {
- const t = type || "javascript";
- const generator = this.map[t];
- return generator ? generator.getSize(module, t) : 0;
- }
-
- generate(module, generateContext) {
- const type = generateContext.type;
- const generator = this.map[type];
- if (!generator) {
- throw new Error(`Generator.byType: no generator specified for ${type}`);
- }
- return generator.generate(module, generateContext);
- }
- }
- module.exports = Generator;
|