Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101954519
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
Sat, Feb 15, 13:37
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Feb 17, 13:37 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24227699
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