[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: AMDPlugin.js
/* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ "use strict"; const RuntimeGlobals = require("../RuntimeGlobals"); const { approve, evaluateToIdentifier, evaluateToString, toConstantDependency } = require("../javascript/JavascriptParserHelpers"); const AMDDefineDependency = require("./AMDDefineDependency"); const AMDDefineDependencyParserPlugin = require("./AMDDefineDependencyParserPlugin"); const AMDRequireArrayDependency = require("./AMDRequireArrayDependency"); const AMDRequireContextDependency = require("./AMDRequireContextDependency"); const AMDRequireDependenciesBlockParserPlugin = require("./AMDRequireDependenciesBlockParserPlugin"); const AMDRequireDependency = require("./AMDRequireDependency"); const AMDRequireItemDependency = require("./AMDRequireItemDependency"); const { AMDDefineRuntimeModule, AMDOptionsRuntimeModule } = require("./AMDRuntimeModules"); const ConstDependency = require("./ConstDependency"); const LocalModuleDependency = require("./LocalModuleDependency"); const UnsupportedDependency = require("./UnsupportedDependency"); /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */ /** @typedef {import("../Compiler")} Compiler */ class AMDPlugin { /** * @param {Record<string, any>} amdOptions the AMD options */ constructor(amdOptions) { this.amdOptions = amdOptions; } /** * Apply the plugin * @param {Compiler} compiler the compiler instance * @returns {void} */ apply(compiler) { const amdOptions = this.amdOptions; compiler.hooks.compilation.tap( "AMDPlugin", (compilation, { contextModuleFactory, normalModuleFactory }) => { compilation.dependencyTemplates.set( AMDRequireDependency, new AMDRequireDependency.Template() ); compilation.dependencyFactories.set( AMDRequireItemDependency, normalModuleFactory ); compilation.dependencyTemplates.set( AMDRequireItemDependency, new AMDRequireItemDependency.Template() ); compilation.dependencyTemplates.set( AMDRequireArrayDependency, new AMDRequireArrayDependency.Template() ); compilation.dependencyFactories.set( AMDRequireContextDependency, contextModuleFactory ); compilation.dependencyTemplates.set( AMDRequireContextDependency, new AMDRequireContextDependency.Template() ); compilation.dependencyTemplates.set( AMDDefineDependency, new AMDDefineDependency.Template() ); compilation.dependencyTemplates.set( UnsupportedDependency, new UnsupportedDependency.Template() ); compilation.dependencyTemplates.set( LocalModuleDependency, new LocalModuleDependency.Template() ); compilation.hooks.runtimeRequirementInModule .for(RuntimeGlobals.amdDefine) .tap("AMDPlugin", (module, set) => { set.add(RuntimeGlobals.require); }); compilation.hooks.runtimeRequirementInModule .for(RuntimeGlobals.amdOptions) .tap("AMDPlugin", (module, set) => { set.add(RuntimeGlobals.requireScope); }); compilation.hooks.runtimeRequirementInTree .for(RuntimeGlobals.amdDefine) .tap("AMDPlugin", (chunk, set) => { compilation.addRuntimeModule(chunk, new AMDDefineRuntimeModule()); }); compilation.hooks.runtimeRequirementInTree .for(RuntimeGlobals.amdOptions) .tap("AMDPlugin", (chunk, set) => { compilation.addRuntimeModule( chunk, new AMDOptionsRuntimeModule(amdOptions) ); }); const handler = (parser, parserOptions) => { if (parserOptions.amd !== undefined && !parserOptions.amd) return; const tapOptionsHooks = (optionExpr, rootName, getMembers) => { parser.hooks.expression .for(optionExpr) .tap( "AMDPlugin", toConstantDependency(parser, RuntimeGlobals.amdOptions, [ RuntimeGlobals.amdOptions ]) ); parser.hooks.evaluateIdentifier .for(optionExpr) .tap( "AMDPlugin", evaluateToIdentifier(optionExpr, rootName, getMembers, true) ); parser.hooks.evaluateTypeof .for(optionExpr) .tap("AMDPlugin", evaluateToString("object")); parser.hooks.typeof .for(optionExpr) .tap( "AMDPlugin", toConstantDependency(parser, JSON.stringify("object")) ); }; new AMDRequireDependenciesBlockParserPlugin(parserOptions).apply( parser ); new AMDDefineDependencyParserPlugin(parserOptions).apply(parser); tapOptionsHooks("define.amd", "define", () => "amd"); tapOptionsHooks("require.amd", "require", () => ["amd"]); tapOptionsHooks( "__webpack_amd_options__", "__webpack_amd_options__", () => [] ); parser.hooks.expression.for("define").tap("AMDPlugin", expr => { const dep = new ConstDependency( RuntimeGlobals.amdDefine, expr.range, [RuntimeGlobals.amdDefine] ); dep.loc = expr.loc; parser.state.module.addPresentationalDependency(dep); return true; }); parser.hooks.typeof .for("define") .tap( "AMDPlugin", toConstantDependency(parser, JSON.stringify("function")) ); parser.hooks.evaluateTypeof .for("define") .tap("AMDPlugin", evaluateToString("function")); parser.hooks.canRename.for("define").tap("AMDPlugin", approve); parser.hooks.rename.for("define").tap("AMDPlugin", expr => { const dep = new ConstDependency( RuntimeGlobals.amdDefine, expr.range, [RuntimeGlobals.amdDefine] ); dep.loc = expr.loc; parser.state.module.addPresentationalDependency(dep); return false; }); parser.hooks.typeof .for("require") .tap( "AMDPlugin", toConstantDependency(parser, JSON.stringify("function")) ); parser.hooks.evaluateTypeof .for("require") .tap("AMDPlugin", evaluateToString("function")); }; normalModuleFactory.hooks.parser .for("javascript/auto") .tap("AMDPlugin", handler); normalModuleFactory.hooks.parser .for("javascript/dynamic") .tap("AMDPlugin", handler); } ); } } module.exports = AMDPlugin;
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.44 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002