First commit
This commit is contained in:
27
hGameTest/node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js
generated
vendored
Normal file
27
hGameTest/node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const ConcatSource = require("webpack-sources").ConcatSource;
|
||||
|
||||
class NodeChunkTemplatePlugin {
|
||||
|
||||
apply(chunkTemplate) {
|
||||
chunkTemplate.plugin("render", function(modules, chunk) {
|
||||
const source = new ConcatSource();
|
||||
source.add(`exports.ids = ${JSON.stringify(chunk.ids)};\nexports.modules = `);
|
||||
source.add(modules);
|
||||
source.add(";");
|
||||
return source;
|
||||
});
|
||||
chunkTemplate.plugin("hash", function(hash) {
|
||||
hash.update("node");
|
||||
hash.update("3");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeChunkTemplatePlugin;
|
||||
25
hGameTest/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js
generated
vendored
Normal file
25
hGameTest/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const NodeWatchFileSystem = require("./NodeWatchFileSystem");
|
||||
const NodeOutputFileSystem = require("./NodeOutputFileSystem");
|
||||
const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
|
||||
const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
|
||||
|
||||
class NodeEnvironmentPlugin {
|
||||
apply(compiler) {
|
||||
compiler.inputFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000);
|
||||
const inputFileSystem = compiler.inputFileSystem;
|
||||
compiler.outputFileSystem = new NodeOutputFileSystem();
|
||||
compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem);
|
||||
compiler.plugin("before-run", (compiler, callback) => {
|
||||
if(compiler.inputFileSystem === inputFileSystem)
|
||||
inputFileSystem.purge();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = NodeEnvironmentPlugin;
|
||||
27
hGameTest/node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js
generated
vendored
Normal file
27
hGameTest/node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const ConcatSource = require("webpack-sources").ConcatSource;
|
||||
|
||||
class NodeHotUpdateChunkTemplatePlugin {
|
||||
|
||||
apply(hotUpdateChunkTemplate) {
|
||||
hotUpdateChunkTemplate.plugin("render", (modulesSource, modules, removedModules, hash, id) => {
|
||||
const source = new ConcatSource();
|
||||
source.add("exports.id = " + JSON.stringify(id) + ";\nexports.modules = ");
|
||||
source.add(modulesSource);
|
||||
source.add(";");
|
||||
return source;
|
||||
});
|
||||
hotUpdateChunkTemplate.plugin("hash", function(hash) {
|
||||
hash.update("NodeHotUpdateChunkTemplatePlugin");
|
||||
hash.update("3");
|
||||
hash.update(this.outputOptions.hotUpdateFunction + "");
|
||||
hash.update(this.outputOptions.library + "");
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = NodeHotUpdateChunkTemplatePlugin;
|
||||
24
hGameTest/node_modules/webpack/lib/node/NodeMainTemplate.runtime.js
generated
vendored
Normal file
24
hGameTest/node_modules/webpack/lib/node/NodeMainTemplate.runtime.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
/*global installedChunks $hotChunkFilename$ hotAddUpdateChunk $hotMainFilename$ */
|
||||
module.exports = function() {
|
||||
function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
|
||||
var chunk = require("./" + $hotChunkFilename$);
|
||||
hotAddUpdateChunk(chunk.id, chunk.modules);
|
||||
}
|
||||
|
||||
function hotDownloadManifest() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
var update = require("./" + $hotMainFilename$);
|
||||
} catch(e) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.resolve(update);
|
||||
}
|
||||
|
||||
function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
|
||||
delete installedChunks[chunkId];
|
||||
}
|
||||
};
|
||||
40
hGameTest/node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js
generated
vendored
Normal file
40
hGameTest/node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
/*global installedChunks $hotChunkFilename$ $require$ hotAddUpdateChunk $hotMainFilename$ */
|
||||
module.exports = function() {
|
||||
function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
|
||||
var filename = require("path").join(__dirname, $hotChunkFilename$);
|
||||
require("fs").readFile(filename, "utf-8", function(err, content) {
|
||||
if(err) {
|
||||
if($require$.onError)
|
||||
return $require$.oe(err);
|
||||
else
|
||||
throw err;
|
||||
}
|
||||
var chunk = {};
|
||||
require("vm").runInThisContext("(function(exports) {" + content + "\n})", filename)(chunk);
|
||||
hotAddUpdateChunk(chunk.id, chunk.modules);
|
||||
});
|
||||
}
|
||||
|
||||
function hotDownloadManifest() { // eslint-disable-line no-unused-vars
|
||||
var filename = require("path").join(__dirname, $hotMainFilename$);
|
||||
return new Promise(function(resolve, reject) {
|
||||
require("fs").readFile(filename, "utf-8", function(err, content) {
|
||||
if(err) return resolve();
|
||||
try {
|
||||
var update = JSON.parse(content);
|
||||
} catch(e) {
|
||||
return reject(e);
|
||||
}
|
||||
resolve(update);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
|
||||
delete installedChunks[chunkId];
|
||||
}
|
||||
};
|
||||
183
hGameTest/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js
generated
vendored
Normal file
183
hGameTest/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js
generated
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const Template = require("../Template");
|
||||
|
||||
module.exports = class NodeMainTemplatePlugin {
|
||||
constructor(asyncChunkLoading) {
|
||||
this.asyncChunkLoading = asyncChunkLoading;
|
||||
}
|
||||
|
||||
apply(mainTemplate) {
|
||||
const asyncChunkLoading = this.asyncChunkLoading;
|
||||
mainTemplate.plugin("local-vars", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
"// object to store loaded chunks",
|
||||
"// \"0\" means \"already loaded\"",
|
||||
"var installedChunks = {",
|
||||
this.indent(chunk.ids.map((id) => `${id}: 0`).join(",\n")),
|
||||
"};"
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
});
|
||||
mainTemplate.plugin("require-extensions", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
"// uncatched error handler for webpack runtime",
|
||||
`${this.requireFn}.oe = function(err) {`,
|
||||
this.indent([
|
||||
"process.nextTick(function() {",
|
||||
this.indent("throw err; // catch this error by using System.import().catch()"),
|
||||
"});"
|
||||
]),
|
||||
"};"
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
});
|
||||
mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
|
||||
const chunkFilename = this.outputOptions.chunkFilename;
|
||||
const chunkMaps = chunk.getChunkMaps();
|
||||
const insertMoreModules = [
|
||||
"var moreModules = chunk.modules, chunkIds = chunk.ids;",
|
||||
"for(var moduleId in moreModules) {",
|
||||
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
|
||||
"}"
|
||||
];
|
||||
if(asyncChunkLoading) {
|
||||
return this.asString([
|
||||
"// \"0\" is the signal for \"already loaded\"",
|
||||
"if(installedChunks[chunkId] === 0)",
|
||||
this.indent([
|
||||
"return Promise.resolve();"
|
||||
]),
|
||||
"// array of [resolve, reject, promise] means \"currently loading\"",
|
||||
"if(installedChunks[chunkId])",
|
||||
this.indent([
|
||||
"return installedChunks[chunkId][2];"
|
||||
]),
|
||||
"// load the chunk and return promise to it",
|
||||
"var promise = new Promise(function(resolve, reject) {",
|
||||
this.indent([
|
||||
"installedChunks[chunkId] = [resolve, reject];",
|
||||
"var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: "\" + chunkId + \"",
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: (length) => {
|
||||
const shortChunkHashMap = {};
|
||||
Object.keys(chunkMaps.hash).forEach((chunkId) => {
|
||||
if(typeof chunkMaps.hash[chunkId] === "string")
|
||||
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
||||
});
|
||||
return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
|
||||
}
|
||||
}) + ";",
|
||||
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
||||
this.indent([
|
||||
"if(err) return reject(err);",
|
||||
"var chunk = {};",
|
||||
"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
|
||||
"(chunk, require, require('path').dirname(filename), filename);"
|
||||
].concat(insertMoreModules).concat([
|
||||
"var callbacks = [];",
|
||||
"for(var i = 0; i < chunkIds.length; i++) {",
|
||||
this.indent([
|
||||
"if(installedChunks[chunkIds[i]])",
|
||||
this.indent([
|
||||
"callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);"
|
||||
]),
|
||||
"installedChunks[chunkIds[i]] = 0;"
|
||||
]),
|
||||
"}",
|
||||
"for(i = 0; i < callbacks.length; i++)",
|
||||
this.indent("callbacks[i]();")
|
||||
])),
|
||||
"});"
|
||||
]),
|
||||
"});",
|
||||
"return installedChunks[chunkId][2] = promise;"
|
||||
]);
|
||||
} else {
|
||||
const request = this.applyPluginsWaterfall("asset-path", JSON.stringify(`./${chunkFilename}`), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: "\" + chunkId + \"",
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: (length) => {
|
||||
const shortChunkHashMap = {};
|
||||
Object.keys(chunkMaps.hash).forEach((chunkId) => {
|
||||
if(typeof chunkMaps.hash[chunkId] === "string")
|
||||
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
||||
});
|
||||
return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
|
||||
}
|
||||
});
|
||||
return this.asString([
|
||||
"// \"0\" is the signal for \"already loaded\"",
|
||||
"if(installedChunks[chunkId] !== 0) {",
|
||||
this.indent([
|
||||
`var chunk = require(${request});`
|
||||
].concat(insertMoreModules).concat([
|
||||
"for(var i = 0; i < chunkIds.length; i++)",
|
||||
this.indent("installedChunks[chunkIds[i]] = 0;")
|
||||
])),
|
||||
"}",
|
||||
"return Promise.resolve();"
|
||||
]);
|
||||
}
|
||||
});
|
||||
mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
|
||||
const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
|
||||
const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
|
||||
const chunkMaps = chunk.getChunkMaps();
|
||||
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: "\" + chunkId + \"",
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: (length) => {
|
||||
const shortChunkHashMap = {};
|
||||
Object.keys(chunkMaps.hash).forEach((chunkId) => {
|
||||
if(typeof chunkMaps.hash[chunkId] === "string")
|
||||
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
||||
});
|
||||
return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
|
||||
}
|
||||
});
|
||||
const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`
|
||||
});
|
||||
return Template.getFunctionContent(asyncChunkLoading ? require("./NodeMainTemplateAsync.runtime.js") : require("./NodeMainTemplate.runtime.js"))
|
||||
.replace(/\$require\$/g, this.requireFn)
|
||||
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
||||
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename);
|
||||
});
|
||||
mainTemplate.plugin("hash", function(hash) {
|
||||
hash.update("node");
|
||||
hash.update("3");
|
||||
hash.update(this.outputOptions.filename + "");
|
||||
hash.update(this.outputOptions.chunkFilename + "");
|
||||
});
|
||||
}
|
||||
};
|
||||
22
hGameTest/node_modules/webpack/lib/node/NodeOutputFileSystem.js
generated
vendored
Normal file
22
hGameTest/node_modules/webpack/lib/node/NodeOutputFileSystem.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const mkdirp = require("mkdirp");
|
||||
|
||||
class NodeOutputFileSystem {
|
||||
constructor() {
|
||||
this.mkdirp = mkdirp;
|
||||
this.mkdir = fs.mkdir.bind(fs);
|
||||
this.rmdir = fs.rmdir.bind(fs);
|
||||
this.unlink = fs.unlink.bind(fs);
|
||||
this.writeFile = fs.writeFile.bind(fs);
|
||||
this.join = path.join.bind(path);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeOutputFileSystem;
|
||||
88
hGameTest/node_modules/webpack/lib/node/NodeSourcePlugin.js
generated
vendored
Normal file
88
hGameTest/node_modules/webpack/lib/node/NodeSourcePlugin.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
const AliasPlugin = require("enhanced-resolve/lib/AliasPlugin");
|
||||
const ParserHelpers = require("../ParserHelpers");
|
||||
const nodeLibsBrowser = require("node-libs-browser");
|
||||
|
||||
module.exports = class NodeSourcePlugin {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
apply(compiler) {
|
||||
const options = this.options;
|
||||
if(options === false) // allow single kill switch to turn off this plugin
|
||||
return;
|
||||
|
||||
function getPathToModule(module, type) {
|
||||
if(type === true || (type === undefined && nodeLibsBrowser[module])) {
|
||||
if(!nodeLibsBrowser[module]) throw new Error(`No browser version for node.js core module ${module} available`);
|
||||
return nodeLibsBrowser[module];
|
||||
} else if(type === "mock") {
|
||||
return require.resolve(`node-libs-browser/mock/${module}`);
|
||||
} else if(type === "empty") {
|
||||
return require.resolve("node-libs-browser/mock/empty");
|
||||
} else return module;
|
||||
}
|
||||
|
||||
function addExpression(parser, name, module, type, suffix) {
|
||||
suffix = suffix || "";
|
||||
parser.plugin(`expression ${name}`, function() {
|
||||
if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return;
|
||||
const mockModule = ParserHelpers.requireFileAsExpression(this.state.module.context, getPathToModule(module, type));
|
||||
return ParserHelpers.addParsedVariableToModule(this, name, mockModule + suffix);
|
||||
});
|
||||
}
|
||||
|
||||
compiler.plugin("compilation", function(compilation, params) {
|
||||
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
|
||||
|
||||
if(parserOptions.node === false)
|
||||
return;
|
||||
|
||||
let localOptions = options;
|
||||
if(parserOptions.node)
|
||||
localOptions = Object.assign({}, localOptions, parserOptions.node);
|
||||
|
||||
if(localOptions.global) {
|
||||
parser.plugin("expression global", function() {
|
||||
const retrieveGlobalModule = ParserHelpers.requireFileAsExpression(this.state.module.context, require.resolve("../../buildin/global.js"));
|
||||
return ParserHelpers.addParsedVariableToModule(this, "global", retrieveGlobalModule);
|
||||
});
|
||||
}
|
||||
if(localOptions.process) {
|
||||
const processType = localOptions.process;
|
||||
addExpression(parser, "process", "process", processType);
|
||||
}
|
||||
if(localOptions.console) {
|
||||
const consoleType = localOptions.console;
|
||||
addExpression(parser, "console", "console", consoleType);
|
||||
}
|
||||
const bufferType = localOptions.Buffer;
|
||||
if(bufferType) {
|
||||
addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer");
|
||||
}
|
||||
if(localOptions.setImmediate) {
|
||||
const setImmediateType = localOptions.setImmediate;
|
||||
addExpression(parser, "setImmediate", "timers", setImmediateType, ".setImmediate");
|
||||
addExpression(parser, "clearImmediate", "timers", setImmediateType, ".clearImmediate");
|
||||
}
|
||||
});
|
||||
});
|
||||
compiler.plugin("after-resolvers", (compiler) => {
|
||||
Object.keys(nodeLibsBrowser).forEach((lib) => {
|
||||
if(options[lib] !== false) {
|
||||
compiler.resolvers.normal.apply(
|
||||
new AliasPlugin("described-resolve", {
|
||||
name: lib,
|
||||
onlyModule: true,
|
||||
alias: getPathToModule(lib, options[lib])
|
||||
}, "resolve")
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
17
hGameTest/node_modules/webpack/lib/node/NodeTargetPlugin.js
generated
vendored
Normal file
17
hGameTest/node_modules/webpack/lib/node/NodeTargetPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const ExternalsPlugin = require("../ExternalsPlugin");
|
||||
|
||||
const builtins = require("module").builtinModules || Object.keys(process.binding("natives"));
|
||||
|
||||
class NodeTargetPlugin {
|
||||
apply(compiler) {
|
||||
new ExternalsPlugin("commonjs", builtins).apply(compiler);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeTargetPlugin;
|
||||
27
hGameTest/node_modules/webpack/lib/node/NodeTemplatePlugin.js
generated
vendored
Normal file
27
hGameTest/node_modules/webpack/lib/node/NodeTemplatePlugin.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const NodeMainTemplatePlugin = require("./NodeMainTemplatePlugin");
|
||||
const NodeChunkTemplatePlugin = require("./NodeChunkTemplatePlugin");
|
||||
const NodeHotUpdateChunkTemplatePlugin = require("./NodeHotUpdateChunkTemplatePlugin");
|
||||
|
||||
class NodeTemplatePlugin {
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
this.asyncChunkLoading = options.asyncChunkLoading;
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.plugin("this-compilation", (compilation) => {
|
||||
compilation.mainTemplate.apply(new NodeMainTemplatePlugin(this.asyncChunkLoading));
|
||||
compilation.chunkTemplate.apply(new NodeChunkTemplatePlugin());
|
||||
compilation.hotUpdateChunkTemplate.apply(new NodeHotUpdateChunkTemplatePlugin());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeTemplatePlugin;
|
||||
72
hGameTest/node_modules/webpack/lib/node/NodeWatchFileSystem.js
generated
vendored
Normal file
72
hGameTest/node_modules/webpack/lib/node/NodeWatchFileSystem.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const Watchpack = require("watchpack");
|
||||
|
||||
class NodeWatchFileSystem {
|
||||
constructor(inputFileSystem) {
|
||||
this.inputFileSystem = inputFileSystem;
|
||||
this.watcherOptions = {
|
||||
aggregateTimeout: 0
|
||||
};
|
||||
this.watcher = new Watchpack(this.watcherOptions);
|
||||
}
|
||||
|
||||
watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
||||
if(!Array.isArray(files))
|
||||
throw new Error("Invalid arguments: 'files'");
|
||||
if(!Array.isArray(dirs))
|
||||
throw new Error("Invalid arguments: 'dirs'");
|
||||
if(!Array.isArray(missing))
|
||||
throw new Error("Invalid arguments: 'missing'");
|
||||
if(typeof callback !== "function")
|
||||
throw new Error("Invalid arguments: 'callback'");
|
||||
if(typeof startTime !== "number" && startTime)
|
||||
throw new Error("Invalid arguments: 'startTime'");
|
||||
if(typeof options !== "object")
|
||||
throw new Error("Invalid arguments: 'options'");
|
||||
if(typeof callbackUndelayed !== "function" && callbackUndelayed)
|
||||
throw new Error("Invalid arguments: 'callbackUndelayed'");
|
||||
const oldWatcher = this.watcher;
|
||||
this.watcher = new Watchpack(options);
|
||||
|
||||
if(callbackUndelayed)
|
||||
this.watcher.once("change", callbackUndelayed);
|
||||
|
||||
this.watcher.once("aggregated", (changes, removals) => {
|
||||
changes = changes.concat(removals);
|
||||
if(this.inputFileSystem && this.inputFileSystem.purge) {
|
||||
this.inputFileSystem.purge(changes);
|
||||
}
|
||||
const times = this.watcher.getTimes();
|
||||
callback(null,
|
||||
changes.filter(file => files.indexOf(file) >= 0).sort(),
|
||||
changes.filter(file => dirs.indexOf(file) >= 0).sort(),
|
||||
changes.filter(file => missing.indexOf(file) >= 0).sort(), times, times);
|
||||
});
|
||||
|
||||
this.watcher.watch(files.concat(missing), dirs.concat(missing), startTime);
|
||||
|
||||
if(oldWatcher) {
|
||||
oldWatcher.close();
|
||||
}
|
||||
return {
|
||||
close: () => {
|
||||
if(this.watcher) {
|
||||
this.watcher.close();
|
||||
this.watcher = null;
|
||||
}
|
||||
},
|
||||
pause: () => {
|
||||
if(this.watcher) {
|
||||
this.watcher.pause();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeWatchFileSystem;
|
||||
Reference in New Issue
Block a user