Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120317937
JsonModulesPlugin.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 3, 12:02
Size
1 KB
Mime Type
text/x-c++
Expires
Sat, Jul 5, 12:02 (2 d)
Engine
blob
Format
Raw Data
Handle
27171518
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
JsonModulesPlugin.js
View Options
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const { validate } = require("schema-utils");
const memorize = require("../util/memorize");
const JsonGenerator = require("./JsonGenerator");
const JsonParser = require("./JsonParser");
/** @typedef {import("../Compiler")} Compiler */
const getParserSchema = memorize(() =>
require("../../schemas/plugins/JsonModulesPluginParser.json")
);
class JsonModulesPlugin {
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(
"JsonModulesPlugin",
(compilation, { normalModuleFactory }) => {
normalModuleFactory.hooks.createParser
.for("json")
.tap("JsonModulesPlugin", parserOptions => {
validate(getParserSchema(), parserOptions, {
name: "Json Modules Plugin",
baseDataPath: "parser"
});
return new JsonParser(parserOptions);
});
normalModuleFactory.hooks.createGenerator
.for("json")
.tap("JsonModulesPlugin", () => {
return new JsonGenerator();
});
}
);
}
}
module.exports = JsonModulesPlugin;
Event Timeline
Log In to Comment