forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
307 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
"use strict"; | ||
|
||
/** @typedef {import("./Module")} Module */ | ||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
/** @typedef {import("webpack-sources").Source} Source */ | ||
|
||
/** | ||
* | ||
*/ | ||
class Generator { | ||
static byType(map) { | ||
return new ByTypeGenerator(map); | ||
} | ||
|
||
/** | ||
* @abstract | ||
* @param {Module} module module for which the code should be generated | ||
* @param {Map<Function, any>} dependencyTemplates mapping from dependencies to templates | ||
* @param {RuntimeTemplate} runtimeTemplate the runtime template | ||
* @param {string} type which kind of code should be generated | ||
* @returns {Source} generated code | ||
*/ | ||
generate(module, dependencyTemplates, runtimeTemplate, type) { | ||
throw new Error("Generator.generate: must be overriden"); | ||
} | ||
} | ||
|
||
class ByTypeGenerator extends Generator { | ||
constructor(map) { | ||
super(); | ||
this.map = map; | ||
} | ||
|
||
generate(module, dependencyTemplates, runtimeTemplate, type) { | ||
const generator = this.map[type]; | ||
if (!generator) { | ||
throw new Error(`Generator.byType: no generator specified for ${type}`); | ||
} | ||
return generator.generate( | ||
module, | ||
dependencyTemplates, | ||
runtimeTemplate, | ||
type | ||
); | ||
} | ||
} | ||
|
||
module.exports = Generator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
*/ | ||
"use strict"; | ||
|
||
const WebpackError = require("../WebpackError"); | ||
|
||
module.exports = class UnsupportedWebAssemblyFeatureError extends WebpackError { | ||
/** @param {string} message Error message */ | ||
constructor(message) { | ||
super(); | ||
this.name = "UnsupportedWebAssemblyFeatureError"; | ||
this.message = message; | ||
this.hideStack = true; | ||
|
||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.