commit
1d72a05fed
56
.eslintrc.js
56
.eslintrc.js
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
plugins: ["prettier", "node", "jest"],
|
||||
plugins: ["prettier", "node", "jest", "jsdoc"],
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:node/recommended",
|
||||
|
@ -33,31 +33,47 @@ module.exports = {
|
|||
"no-loop-func": "warn",
|
||||
indent: "off",
|
||||
"no-console": "off",
|
||||
"valid-jsdoc": [
|
||||
"error",
|
||||
{
|
||||
prefer: {
|
||||
return: "returns",
|
||||
prop: "property",
|
||||
memberof: "DONTUSE",
|
||||
class: "DONTUSE",
|
||||
inheritdoc: "DONTUSE",
|
||||
description: "DONTUSE",
|
||||
readonly: "DONTUSE"
|
||||
},
|
||||
preferType: {
|
||||
"*": "any"
|
||||
},
|
||||
requireReturnType: true
|
||||
}
|
||||
],
|
||||
"node/no-unsupported-features": "error",
|
||||
"node/no-deprecated-api": "error",
|
||||
"node/no-missing-import": "error",
|
||||
"node/no-missing-require": ["error", { allowModules: ["webpack"] }],
|
||||
"node/no-unpublished-bin": "error",
|
||||
"node/no-unpublished-require": "error",
|
||||
"node/process-exit-as-throw": "error"
|
||||
"node/process-exit-as-throw": "error",
|
||||
"jsdoc/require-hyphen-before-param-description": ["error", "never"],
|
||||
"jsdoc/check-tag-names": "error",
|
||||
"jsdoc/check-param-names": "error",
|
||||
"jsdoc/require-param-description": "error",
|
||||
"jsdoc/require-param-name": "error",
|
||||
"jsdoc/require-param-type": "error",
|
||||
"jsdoc/require-param": "error",
|
||||
"jsdoc/require-returns-description": "error",
|
||||
"jsdoc/require-returns-type": "error",
|
||||
"jsdoc/require-returns": "error"
|
||||
},
|
||||
settings: {
|
||||
jsdoc: {
|
||||
// supported tags https://github.com/microsoft/TypeScript-wiki/blob/master/JSDoc-support-in-JavaScript.md
|
||||
tagNamePreference: {
|
||||
...(['implements', 'const', 'memberof', 'readonly', 'yields'].reduce((acc, tag) => {
|
||||
acc[tag] = {
|
||||
message: `@${tag} currently not supported in Typescript`
|
||||
};
|
||||
return acc;
|
||||
}, {})),
|
||||
extends: "extends",
|
||||
return: "returns",
|
||||
constructor: "constructor",
|
||||
prop: "property",
|
||||
arg: "param",
|
||||
augments: "extends",
|
||||
description: false,
|
||||
desc: false,
|
||||
inheritdoc: false,
|
||||
class: false
|
||||
},
|
||||
overrideReplacesDocs: false
|
||||
}
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
|
|
@ -243,7 +243,7 @@ declare module "webpack-sources" {
|
|||
map: Object;
|
||||
};
|
||||
|
||||
updateHash(hash: import("./lib/util/createHash").Hash): void;
|
||||
updateHash(hash: import("./lib/util/Hash")): void;
|
||||
|
||||
source(): string | Buffer;
|
||||
}
|
||||
|
|
|
@ -1170,7 +1170,7 @@ export interface OutputOptions {
|
|||
/**
|
||||
* Algorithm used for generation the hash (see node.js crypto package)
|
||||
*/
|
||||
hashFunction?: string | (new () => import("../lib/util/createHash").Hash);
|
||||
hashFunction?: string | typeof import("../lib/util/Hash");
|
||||
/**
|
||||
* Any string which is added to the hash to salt it
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Ivan Kopeykin @vankop
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/;
|
||||
|
||||
/**
|
||||
* @param {string=} method method name
|
||||
* @returns {string} message
|
||||
*/
|
||||
function createMessage(method) {
|
||||
return `Abstract method${method ? " " + method : ""}. Must be overridden.`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Message() {
|
||||
this.stack = undefined;
|
||||
Error.captureStackTrace(this);
|
||||
/** @type {RegExpMatchArray} */
|
||||
const match = this.stack.split("\n")[3].match(CURRENT_METHOD_REGEXP);
|
||||
|
||||
this.message = match && match[1] ? createMessage(match[1]) : createMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Error for abstract method
|
||||
* @example
|
||||
* class FooClass {
|
||||
* abstractMethod() {
|
||||
* throw new AbstractMethodError(); // error message: Abstract method FooClass.abstractMethod. Must be overriden.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
class AbstractMethodError extends WebpackError {
|
||||
constructor() {
|
||||
super(new Message().message);
|
||||
this.name = "AbstractMethodError";
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AbstractMethodError;
|
|
@ -13,7 +13,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
|
||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
class AsyncDependenciesBlock extends DependenciesBlock {
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ const { arrayToSetDeprecation } = require("./util/deprecation");
|
|||
/** @typedef {import("./Compilation").PathData} PathData */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @typedef {Object} WithId an object who has an id property *
|
||||
|
|
|
@ -10,7 +10,7 @@ const { SyncWaterfallHook, SyncHook } = require("tapable");
|
|||
/** @typedef {import("./ModuleTemplate")} ModuleTemplate */
|
||||
/** @typedef {import("./Chunk")} Chunk */
|
||||
/** @typedef {import("./Module")} Module} */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash} */
|
||||
/** @typedef {import("./util/Hash")} Hash} */
|
||||
/** @typedef {import("webpack-sources").Source} Source} */
|
||||
/** @typedef {import("./ModuleTemplate").RenderContext} RenderContext} */
|
||||
/** @typedef {import("./MainTemplate").UpdateHashForChunkContext} UpdateHashForChunkContext} */
|
||||
|
|
|
@ -74,7 +74,7 @@ const { arrayToSetDeprecation } = require("./util/deprecation");
|
|||
/** @typedef {import("./dependencies/EntryDependency")} EntryDependency */
|
||||
/** @typedef {import("./stats/StatsFactory")} StatsFactory */
|
||||
/** @typedef {import("./stats/StatsPrinter")} StatsPrinter */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @callback Callback
|
||||
|
@ -149,6 +149,7 @@ const { arrayToSetDeprecation } = require("./util/deprecation");
|
|||
* @property {string=} contentHash
|
||||
* @property {function(number): string=} contentHashWithLength
|
||||
* @property {boolean=} noChunkHash
|
||||
* @property {string=} url
|
||||
*/
|
||||
|
||||
// TODO webpack 6: remove
|
||||
|
@ -2255,7 +2256,9 @@ class Compilation {
|
|||
for (const module of this.modules) {
|
||||
const moduleHash = createHash(hashFunction);
|
||||
module.updateHash(moduleHash, chunkGraph);
|
||||
const moduleHashDigest = moduleHash.digest(hashDigest);
|
||||
const moduleHashDigest = /** @type {string} */ (moduleHash.digest(
|
||||
hashDigest
|
||||
));
|
||||
chunkGraph.setModuleHashes(
|
||||
module,
|
||||
moduleHashDigest,
|
||||
|
@ -2310,7 +2313,9 @@ class Compilation {
|
|||
if (!chunkGraph.getModuleHash(module)) {
|
||||
const moduleHash = createHash(hashFunction);
|
||||
module.updateHash(moduleHash, chunkGraph);
|
||||
const moduleHashDigest = moduleHash.digest(hashDigest);
|
||||
const moduleHashDigest = /** @type {string} */ (moduleHash.digest(
|
||||
hashDigest
|
||||
));
|
||||
chunkGraph.setModuleHashes(
|
||||
module,
|
||||
moduleHashDigest,
|
||||
|
@ -2333,7 +2338,7 @@ class Compilation {
|
|||
runtimeTemplate: this.runtimeTemplate
|
||||
});
|
||||
this.hooks.chunkHash.call(chunk, chunkHash);
|
||||
chunk.hash = chunkHash.digest(hashDigest);
|
||||
chunk.hash = /** @type {string} */ (chunkHash.digest(hashDigest));
|
||||
hash.update(chunk.hash);
|
||||
chunk.renderedHash = chunk.hash.substr(0, hashDigestLength);
|
||||
this.hooks.contentHash.call(chunk);
|
||||
|
@ -2341,7 +2346,7 @@ class Compilation {
|
|||
this.errors.push(new ChunkRenderError(chunk, "", err));
|
||||
}
|
||||
}
|
||||
this.fullHash = hash.digest(hashDigest);
|
||||
this.fullHash = /** @type {string} */ (hash.digest(hashDigest));
|
||||
this.hash = this.fullHash.substr(0, hashDigestLength);
|
||||
}
|
||||
|
||||
|
@ -2357,7 +2362,7 @@ class Compilation {
|
|||
const hash = createHash(hashFunction);
|
||||
hash.update(this.fullHash);
|
||||
hash.update(update);
|
||||
this.fullHash = hash.digest(hashDigest);
|
||||
this.fullHash = /** @type {string} */ (hash.digest(hashDigest));
|
||||
this.hash = this.fullHash.substr(0, hashDigestLength);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ const StaticExportsDependency = require("./dependencies/StaticExportsDependency"
|
|||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
class DelegatedModule extends Module {
|
||||
constructor(sourceRequest, data, type, userRequest, originalRequest) {
|
||||
|
|
|
@ -11,7 +11,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
||||
/** @typedef {import("./Dependency")} Dependency */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/** @typedef {(d: Dependency) => boolean} DependencyFilterFunction */
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ const DependencyReference = require("./dependencies/DependencyReference");
|
|||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/** @typedef {Object} SourcePosition
|
||||
* @property {number} line
|
||||
|
|
|
@ -44,7 +44,7 @@ class DependencyTemplates {
|
|||
const hash = createHash("md4");
|
||||
hash.update(this._hash);
|
||||
hash.update(part);
|
||||
this._hash = hash.digest("hex");
|
||||
this._hash = /** @type {string} */ (hash.digest("hex"));
|
||||
}
|
||||
|
||||
getHash() {
|
||||
|
|
|
@ -18,7 +18,7 @@ const RuntimeGlobals = require("./RuntimeGlobals");
|
|||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
class DllModule extends Module {
|
||||
constructor(context, dependencies, name) {
|
||||
|
|
|
@ -22,7 +22,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @param {string|string[]} variableName the variable name or path
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
const Chunk = require("./Chunk");
|
||||
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
class HotUpdateChunk extends Chunk {
|
||||
constructor() {
|
||||
|
|
|
@ -213,9 +213,8 @@ class JavascriptModulesPlugin {
|
|||
if (hotUpdateChunk) {
|
||||
hash.update(JSON.stringify(hotUpdateChunk.removedModules));
|
||||
}
|
||||
chunk.contentHash.javascript = hash
|
||||
.digest(hashDigest)
|
||||
.substr(0, hashDigestLength);
|
||||
const digest = /** @type {string} */ (hash.digest(hashDigest));
|
||||
chunk.contentHash.javascript = digest.substr(0, hashDigestLength);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -20,7 +20,7 @@ const Template = require("./Template");
|
|||
/** @typedef {import("./ModuleTemplate")} ModuleTemplate */
|
||||
/** @typedef {import("./Chunk")} Chunk */
|
||||
/** @typedef {import("./Module")} Module} */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash} */
|
||||
/** @typedef {import("./util/Hash")} Hash} */
|
||||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates} */
|
||||
/** @typedef {import("./ModuleTemplate").RenderContext} RenderContext} */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate} */
|
||||
|
|
|
@ -22,8 +22,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @template T @typedef {import("./util/SortableSet")<T>} SortableSet<T> */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
|
||||
/**
|
||||
* @typedef {Object} SourceContext
|
||||
|
|
|
@ -45,7 +45,8 @@ const getBefore = (str, token) => {
|
|||
const getHash = str => {
|
||||
const hash = createHash("md4");
|
||||
hash.update(str);
|
||||
return hash.digest("hex").substr(0, 4);
|
||||
const digest = /** @type {string} */ (hash.digest("hex"));
|
||||
return digest.substr(0, 4);
|
||||
};
|
||||
|
||||
const asRegExp = test => {
|
||||
|
|
|
@ -14,7 +14,7 @@ const { SyncWaterfallHook, SyncHook } = require("tapable");
|
|||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @typedef {Object} RenderContext
|
||||
|
|
|
@ -40,7 +40,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./Module").SourceContext} SourceContext */
|
||||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @typedef {Object} ParserState
|
||||
|
@ -522,7 +522,7 @@ class NormalModule extends Module {
|
|||
}
|
||||
hash.update("meta");
|
||||
hash.update(JSON.stringify(this.buildMeta));
|
||||
this.buildInfo.hash = hash.digest("hex");
|
||||
this.buildInfo.hash = /** @type {string} */ (hash.digest("hex"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
/**
|
||||
* Gets the value at path of object
|
||||
* @param {object} obj - object to query
|
||||
* @param {string} path - query path
|
||||
* @param {object} obj object to query
|
||||
* @param {string} path query path
|
||||
* @returns {any} - if {@param path} requests element from array, then `undefined` will be returned
|
||||
*/
|
||||
const getProperty = (obj, path) => {
|
||||
|
@ -22,9 +22,9 @@ const getProperty = (obj, path) => {
|
|||
|
||||
/**
|
||||
* Sets the value at path of object. Stops execution, if {@param path} requests element from array to be set
|
||||
* @param {object} obj - object to query
|
||||
* @param {string} path - query path
|
||||
* @param {any} value - value to be set
|
||||
* @param {object} obj object to query
|
||||
* @param {string} path query path
|
||||
* @param {any} value value to be set
|
||||
* @returns {void}
|
||||
*/
|
||||
const setProperty = (obj, path, value) => {
|
||||
|
@ -66,7 +66,7 @@ class OptionsDefaulter {
|
|||
|
||||
/**
|
||||
* Enhancing {@param options} with default values
|
||||
* @param {object} options - provided options
|
||||
* @param {object} options provided options
|
||||
* @returns {object} - enhanced options
|
||||
* @throws {Error} - will throw error, if configuration value is other then `undefined` or {@link ConfigType}
|
||||
*/
|
||||
|
@ -123,9 +123,9 @@ class OptionsDefaulter {
|
|||
|
||||
/**
|
||||
* Builds up default values
|
||||
* @param {string} name - option path
|
||||
* @param {ConfigType | any} config - if {@param def} is provided, then only {@link ConfigType} is allowed
|
||||
* @param {MakeConfigHandler | CallConfigHandler | AppendConfigValues} [def] - defaults
|
||||
* @param {string} name option path
|
||||
* @param {ConfigType | any} config if {@param def} is provided, then only {@link ConfigType} is allowed
|
||||
* @param {MakeConfigHandler | CallConfigHandler | AppendConfigValues} [def] defaults
|
||||
* @returns {void}
|
||||
*/
|
||||
set(name, config, def) {
|
||||
|
|
|
@ -18,7 +18,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
class RawModule extends Module {
|
||||
constructor(source, identifier, readableIdentifier) {
|
||||
|
|
|
@ -17,7 +17,7 @@ const Module = require("./Module");
|
|||
/** @typedef {import("./Module").SourceContext} SourceContext */
|
||||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./util/createHash").Hash} Hash */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/** @typedef {SourceContext} GenerateContext */
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ const { relative, dirname } = require("./util/fs");
|
|||
|
||||
const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");
|
||||
|
||||
/** @typedef {import("source-map").RawSourceMap} SourceMap */
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
||||
/** @typedef {import("./Chunk")} Chunk */
|
||||
|
@ -22,53 +23,55 @@ const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");
|
|||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
/**
|
||||
* @typedef {object} SourceMapTask
|
||||
* @property {Source} asset
|
||||
* @property {(string | Module)[]} modules
|
||||
* @property {string} source
|
||||
* @property {string} file
|
||||
* @property {SourceMap} sourceMap
|
||||
* @property {Chunk} chunk
|
||||
*/
|
||||
|
||||
/** @type {WeakMap<Source, { file: string, assets: Record<string, Source>}>} */
|
||||
const assetsCache = new WeakMap();
|
||||
|
||||
/**
|
||||
* @typedef {Object} SourceMapObject
|
||||
* @property {string[]} sources
|
||||
* @property {string[]=} sourcesContent
|
||||
* @property {string} sourceRoot
|
||||
* @property {string} file
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} SourceMapDevToolTask
|
||||
* @property {Chunk} chunk
|
||||
* @property {string} file
|
||||
* @property {Source} asset
|
||||
* @property {string} source
|
||||
* @property {SourceMapObject} sourceMap
|
||||
* @property {(Module|string)[]} modules
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {string} file the filename
|
||||
* @param {Chunk} chunk the chunk
|
||||
* @param {TODO} options options
|
||||
* @param {Compilation} compilation the compilation
|
||||
* @returns {SourceMapDevToolTask|undefined} the task for this file
|
||||
* Creating {@link SourceMapTask} for given file
|
||||
* @param {string} file current compiled file
|
||||
* @param {Chunk} chunk related chunk
|
||||
* @param {SourceMapDevToolPluginOptions} options source map options
|
||||
* @param {Compilation} compilation compilation instance
|
||||
* @returns {SourceMapTask | undefined} created task instance or `undefined`
|
||||
*/
|
||||
const getTaskForFile = (file, chunk, options, compilation) => {
|
||||
const asset = compilation.assets[file];
|
||||
const cache = assetsCache.get(asset);
|
||||
/**
|
||||
* If presented in cache, reassigns assets. Cache assets already have source maps.
|
||||
*/
|
||||
if (cache && cache.file === file) {
|
||||
for (const cachedFile in cache.assets) {
|
||||
compilation.assets[cachedFile] = cache.assets[cachedFile];
|
||||
/**
|
||||
* Add file to chunk, if not presented there
|
||||
*/
|
||||
if (cachedFile !== file) chunk.files.add(cachedFile);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let source;
|
||||
/** @type {SourceMapObject} */
|
||||
/** @type {SourceMap} */
|
||||
let sourceMap;
|
||||
/**
|
||||
* Check if asset can build source map
|
||||
*/
|
||||
if (asset.sourceAndMap) {
|
||||
const sourceAndMap = asset.sourceAndMap(options);
|
||||
sourceMap = /** @type {SourceMapObject} */ (sourceAndMap.map);
|
||||
sourceMap = /** @type {SourceMap} */ (sourceAndMap.map);
|
||||
source = sourceAndMap.source;
|
||||
} else {
|
||||
sourceMap = /** @type {SourceMapObject} */ (asset.map(options));
|
||||
sourceMap = /** @type {SourceMap} */ (asset.map(options));
|
||||
source = asset.source();
|
||||
}
|
||||
if (!sourceMap || typeof source !== "string") return;
|
||||
|
@ -89,7 +92,8 @@ const getTaskForFile = (file, chunk, options, compilation) => {
|
|||
|
||||
class SourceMapDevToolPlugin {
|
||||
/**
|
||||
* @param {SourceMapDevToolPluginOptions=} options options object
|
||||
* @param {SourceMapDevToolPluginOptions} [options] options object
|
||||
* @throws {Error} throws error, if got more than 1 arguments
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
validateOptions(schema, options, "SourceMap DevTool Plugin");
|
||||
|
@ -101,17 +105,22 @@ class SourceMapDevToolPlugin {
|
|||
options.append === false
|
||||
? false
|
||||
: options.append || "\n//# sourceMappingURL=[url]";
|
||||
/** @type {string | Function} */
|
||||
this.moduleFilenameTemplate =
|
||||
options.moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]";
|
||||
/** @type {string | Function} */
|
||||
this.fallbackModuleFilenameTemplate =
|
||||
options.fallbackModuleFilenameTemplate ||
|
||||
"webpack://[namespace]/[resourcePath]?[hash]";
|
||||
/** @type {string} */
|
||||
this.namespace = options.namespace || "";
|
||||
/** @type {SourceMapDevToolPluginOptions} */
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Compiler} compiler webpack compiler
|
||||
* Apply compiler
|
||||
* @param {Compiler} compiler compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
|
@ -137,7 +146,12 @@ class SourceMapDevToolPlugin {
|
|||
"SourceMapDevToolPlugin",
|
||||
chunks => {
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
/** @type {Map<string | Module, string>} */
|
||||
const moduleToSourceNameMapping = new Map();
|
||||
/**
|
||||
* @type {Function}
|
||||
* @returns {void}
|
||||
*/
|
||||
const reportProgress =
|
||||
ProgressPlugin.getReporter(compilation.compiler) || (() => {});
|
||||
|
||||
|
@ -154,7 +168,7 @@ class SourceMapDevToolPlugin {
|
|||
}
|
||||
|
||||
reportProgress(0.0);
|
||||
/** @type {SourceMapDevToolTask[]} */
|
||||
/** @type {SourceMapTask[]} */
|
||||
const tasks = [];
|
||||
files.forEach(({ file, chunk }, idx) => {
|
||||
reportProgress(
|
||||
|
@ -162,6 +176,7 @@ class SourceMapDevToolPlugin {
|
|||
file,
|
||||
"generate SourceMap"
|
||||
);
|
||||
/** @type {SourceMapTask | undefined} */
|
||||
const task = getTaskForFile(file, chunk, options, compilation);
|
||||
|
||||
if (task) {
|
||||
|
@ -192,10 +207,15 @@ class SourceMapDevToolPlugin {
|
|||
});
|
||||
|
||||
reportProgress(0.5, "resolve sources");
|
||||
/** @type {Set<string>} */
|
||||
const usedNamesSet = new Set(moduleToSourceNameMapping.values());
|
||||
/** @type {Set<string>} */
|
||||
const conflictDetectionSet = new Set();
|
||||
|
||||
// all modules in defined order (longest identifier first)
|
||||
/**
|
||||
* all modules in defined order (longest identifier first)
|
||||
* @type {Array<string | Module>}
|
||||
*/
|
||||
const allModules = Array.from(moduleToSourceNameMapping.keys()).sort(
|
||||
(a, b) => {
|
||||
const ai = typeof a === "string" ? a : a.identifier();
|
||||
|
@ -278,7 +298,7 @@ class SourceMapDevToolPlugin {
|
|||
const sourceMapString = JSON.stringify(sourceMap);
|
||||
if (sourceMapFilename) {
|
||||
let filename = file;
|
||||
let sourceMapFile = compilation.getPath(sourceMapFilename, {
|
||||
const pathParams = {
|
||||
chunk,
|
||||
filename: options.fileContext
|
||||
? relative(
|
||||
|
@ -287,10 +307,14 @@ class SourceMapDevToolPlugin {
|
|||
`/${filename}`
|
||||
)
|
||||
: filename,
|
||||
contentHash: createHash("md4")
|
||||
contentHash: /** @type {string} */ (createHash("md4")
|
||||
.update(sourceMapString)
|
||||
.digest("hex")
|
||||
});
|
||||
.digest("hex"))
|
||||
};
|
||||
let sourceMapFile = compilation.getPath(
|
||||
sourceMapFilename,
|
||||
pathParams
|
||||
);
|
||||
const sourceMapUrl = options.publicPath
|
||||
? options.publicPath + sourceMapFile
|
||||
: relative(
|
||||
|
@ -298,15 +322,21 @@ class SourceMapDevToolPlugin {
|
|||
dirname(outputFs, `/${file}`),
|
||||
`/${sourceMapFile}`
|
||||
);
|
||||
/**
|
||||
* Add source map url to compilation asset, if {@link currentSourceMappingURLComment} presented
|
||||
*/
|
||||
if (currentSourceMappingURLComment !== false) {
|
||||
assets[file] = compilation.assets[file] = new ConcatSource(
|
||||
new RawSource(source),
|
||||
currentSourceMappingURLComment.replace(
|
||||
/\[url\]/g,
|
||||
sourceMapUrl
|
||||
compilation.getPath(
|
||||
currentSourceMappingURLComment,
|
||||
Object.assign({ url: sourceMapUrl }, pathParams)
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Add source map file to compilation assets and chunk files
|
||||
*/
|
||||
assets[sourceMapFile] = compilation.assets[
|
||||
sourceMapFile
|
||||
] = new RawSource(sourceMapString);
|
||||
|
@ -317,6 +347,9 @@ class SourceMapDevToolPlugin {
|
|||
"SourceMapDevToolPlugin: append can't be false when no filename is provided"
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Add source map as data url to asset
|
||||
*/
|
||||
assets[file] = compilation.assets[file] = new ConcatSource(
|
||||
new RawSource(source),
|
||||
currentSourceMappingURLComment
|
||||
|
|
|
@ -71,7 +71,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|||
class Template {
|
||||
/**
|
||||
*
|
||||
* @param {Function} fn - a runtime function (.runtime.js) "template"
|
||||
* @param {Function} fn a runtime function (.runtime.js) "template"
|
||||
* @returns {string} the updated and normalized function string
|
||||
*/
|
||||
static getFunctionContent(fn) {
|
||||
|
|
|
@ -236,6 +236,11 @@ const replacePathVariables = (path, data) => {
|
|||
);
|
||||
}
|
||||
|
||||
// Other things
|
||||
if (data.url) {
|
||||
replacements.set("url", replacer(data.url));
|
||||
}
|
||||
|
||||
if (typeof path === "function") {
|
||||
path = path(data);
|
||||
}
|
||||
|
|
|
@ -83,8 +83,8 @@ class Profiler {
|
|||
}
|
||||
|
||||
/**
|
||||
* an object that wraps Tracer and Profiler with a counter
|
||||
* @typedef {Object} Trace
|
||||
* @description an object that wraps Tracer and Profiler with a counter
|
||||
* @property {Tracer} trace instance of Tracer
|
||||
* @property {number} counter Counter
|
||||
* @property {Profiler} profiler instance of Profiler
|
||||
|
|
|
@ -17,7 +17,7 @@ const NullDependency = require("./NullDependency");
|
|||
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
class CachedConstDependency extends NullDependency {
|
||||
constructor(expression, range, identifier) {
|
||||
|
|
|
@ -13,7 +13,7 @@ const NullDependency = require("./NullDependency");
|
|||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
class ConstDependency extends NullDependency {
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../ModuleGraph").ExportsInfo} ExportsInfo */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
/** @typedef {"missing"|"unused"|"empty-star"|"reexport-non-harmony-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-partial-namespace-object"|"reexport-non-harmony-default-strict"|"reexport-fake-namespace-object"|"reexport-non-harmony-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
class HarmonyImportDependency extends ModuleDependency {
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../InitFragment")} InitFragment */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("./DependencyReference")} DependencyReference */
|
||||
|
||||
class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
|
||||
|
|
|
@ -16,7 +16,7 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
const idsSymbol = Symbol("HarmonyImportSpecifierDependency.ids");
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ const NullDependency = require("./NullDependency");
|
|||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
class ModuleDecoratorDependency extends NullDependency {
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@ const DependencyTemplate = require("../DependencyTemplate");
|
|||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
class NullDependency extends Dependency {
|
||||
get type() {
|
||||
|
|
|
@ -16,7 +16,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|||
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @param {string[]|null} path the property path array
|
||||
|
|
|
@ -12,7 +12,7 @@ const NullDependency = require("./NullDependency");
|
|||
/** @typedef {import("../Dependency").ExportSpec} ExportSpec */
|
||||
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
class StaticExportsDependency extends NullDependency {
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,9 @@ class HashedModuleIdsPlugin {
|
|||
const ident = getFullModuleName(module, context, compiler.root);
|
||||
const hash = createHash(options.hashFunction);
|
||||
hash.update(ident || "");
|
||||
const hashId = hash.digest(options.hashDigest);
|
||||
const hashId = /** @type {string} */ (hash.digest(
|
||||
options.hashDigest
|
||||
));
|
||||
let len = options.hashDigestLength;
|
||||
while (usedIds.has(hashId.substr(0, len))) len++;
|
||||
const moduleId = hashId.substr(0, len);
|
||||
|
|
|
@ -22,7 +22,8 @@ const numberHash = require("../util/numberHash");
|
|||
const getHash = (str, len) => {
|
||||
const hash = createHash("md4");
|
||||
hash.update(str);
|
||||
return hash.digest("hex").substr(0, len);
|
||||
const digest = /** @type {string} */ (hash.digest("hex"));
|
||||
return digest.substr(0, len);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ const propertyAccess = require("../util/propertyAccess");
|
|||
/** @typedef {import("../RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../util/createHash").Hash} Hash */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @typedef {Object} ReexportInfo
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class Hash {
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string|Buffer} data data
|
||||
* @param {string=} inputEncoding data encoding
|
||||
* @returns {this} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
const AbstractMethodError = require("../AbstractMethodError");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {string=} encoding encoding of the return value
|
||||
* @returns {string|Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
const AbstractMethodError = require("../AbstractMethodError");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Hash;
|
|
@ -50,6 +50,7 @@ const cleverMerge = (first, second) => {
|
|||
const secondValue = second[key];
|
||||
if (typeof secondValue !== "object" || secondValue === null) {
|
||||
newObject[key] = secondValue;
|
||||
continue;
|
||||
}
|
||||
if (Array.isArray(secondValue)) {
|
||||
const firstValue = newObject[key];
|
||||
|
|
|
@ -5,24 +5,26 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {{new(): Hash}} HashConstructor */
|
||||
/**
|
||||
* @typedef {Object} Hash
|
||||
* @property {function(string|Buffer, string=): Hash} update
|
||||
* @property {function(string): string} digest
|
||||
*/
|
||||
const Hash = require("./Hash");
|
||||
|
||||
const BULK_SIZE = 1000;
|
||||
|
||||
/**
|
||||
* @implements {Hash}
|
||||
*/
|
||||
class BulkUpdateDecorator {
|
||||
class BulkUpdateDecorator extends Hash {
|
||||
/**
|
||||
* @param {Hash} hash hash
|
||||
*/
|
||||
constructor(hash) {
|
||||
super();
|
||||
this.hash = hash;
|
||||
this.buffer = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string|Buffer} data data
|
||||
* @param {string=} inputEncoding data encoding
|
||||
* @returns {this} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (
|
||||
inputEncoding !== undefined ||
|
||||
|
@ -44,6 +46,11 @@ class BulkUpdateDecorator {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {string=} encoding encoding of the return value
|
||||
* @returns {string|Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
if (this.buffer.length > 0) {
|
||||
this.hash.update(this.buffer);
|
||||
|
@ -55,12 +62,21 @@ class BulkUpdateDecorator {
|
|||
}
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
class DebugHash {
|
||||
/**
|
||||
* istanbul ignore next
|
||||
*/
|
||||
class DebugHash extends Hash {
|
||||
constructor() {
|
||||
super();
|
||||
this.string = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string|Buffer} data data
|
||||
* @param {string=} inputEncoding data encoding
|
||||
* @returns {this} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (typeof data !== "string") data = data.toString("utf-8");
|
||||
if (data.startsWith("debug-digest-")) {
|
||||
|
@ -70,6 +86,11 @@ class DebugHash {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {string=} encoding encoding of the return value
|
||||
* @returns {string|Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
return "debug-digest-" + Buffer.from(this.string).toString("hex");
|
||||
}
|
||||
|
@ -79,7 +100,7 @@ let crypto = undefined;
|
|||
|
||||
/**
|
||||
* Creates a hash by name or function
|
||||
* @param {string | HashConstructor} algorithm the algorithm name or a constructor creating a hash
|
||||
* @param {string | typeof Hash} algorithm the algorithm name or a constructor creating a hash
|
||||
* @returns {Hash} the hash
|
||||
*/
|
||||
module.exports = algorithm => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
/**
|
||||
* Convert an object into an ES6 map
|
||||
*
|
||||
* @param {object} obj - any object type that works with Object.entries()
|
||||
* @param {object} obj any object type that works with Object.entries()
|
||||
* @returns {Map<string, any>} an ES6 Map of KV pairs
|
||||
*/
|
||||
module.exports = function objectToMap(obj) {
|
||||
|
|
|
@ -48,7 +48,7 @@ const compose = (...fns) => {
|
|||
/**
|
||||
* Removes the start instruction
|
||||
*
|
||||
* @param {Object} state - unused state
|
||||
* @param {Object} state unused state
|
||||
* @returns {ArrayBufferTransform} transform
|
||||
*/
|
||||
const removeStartFunc = state => bin => {
|
||||
|
@ -62,7 +62,7 @@ const removeStartFunc = state => bin => {
|
|||
/**
|
||||
* Get imported globals
|
||||
*
|
||||
* @param {Object} ast - Module's AST
|
||||
* @param {Object} ast Module's AST
|
||||
* @returns {Array<t.ModuleImport>} - nodes
|
||||
*/
|
||||
const getImportedGlobals = ast => {
|
||||
|
@ -96,7 +96,7 @@ const getCountImportedFunc = ast => {
|
|||
/**
|
||||
* Get next type index
|
||||
*
|
||||
* @param {Object} ast - Module's AST
|
||||
* @param {Object} ast Module's AST
|
||||
* @returns {t.Index} - index
|
||||
*/
|
||||
const getNextTypeIndex = ast => {
|
||||
|
@ -116,8 +116,8 @@ const getNextTypeIndex = ast => {
|
|||
* in order to have the correct index we shift the index by number of external
|
||||
* functions.
|
||||
*
|
||||
* @param {Object} ast - Module's AST
|
||||
* @param {Number} countImportedFunc - number of imported funcs
|
||||
* @param {Object} ast Module's AST
|
||||
* @param {Number} countImportedFunc number of imported funcs
|
||||
* @returns {t.Index} - index
|
||||
*/
|
||||
const getNextFuncIndex = (ast, countImportedFunc) => {
|
||||
|
@ -163,7 +163,7 @@ const createDefaultInitForGlobal = globalType => {
|
|||
*
|
||||
* Note that globals will become mutable.
|
||||
*
|
||||
* @param {Object} state - unused state
|
||||
* @param {Object} state unused state
|
||||
* @returns {ArrayBufferTransform} transform
|
||||
*/
|
||||
const rewriteImportedGlobals = state => bin => {
|
||||
|
@ -285,7 +285,7 @@ const rewriteImports = ({ ast, usedDependencyMap }) => bin => {
|
|||
* The init function fills the globals given input arguments.
|
||||
*
|
||||
* @param {Object} state transformation state
|
||||
* @param {Object} state.ast - Module's ast
|
||||
* @param {Object} state.ast Module's ast
|
||||
* @param {t.Identifier} state.initFuncId identifier of the init function
|
||||
* @param {t.Index} state.startAtFuncOffset index of the start function
|
||||
* @param {t.ModuleImport[]} state.importedGlobals list of imported globals
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
"eslint": "^5.8.0",
|
||||
"eslint-config-prettier": "^4.0.0",
|
||||
"eslint-plugin-jest": "^22.2.2",
|
||||
"eslint-plugin-jsdoc": "^15.3.2",
|
||||
"eslint-plugin-node": "^8.0.0",
|
||||
"eslint-plugin-prettier": "^3.0.0",
|
||||
"file-loader": "^3.0.1",
|
||||
|
|
|
@ -1091,7 +1091,7 @@
|
|||
},
|
||||
{
|
||||
"instanceof": "Function",
|
||||
"tsType": "(new () => import('../lib/util/createHash').Hash)"
|
||||
"tsType": "typeof import('../lib/util/Hash')"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
|
||||
const AbstractMethodError = require("../lib/AbstractMethodError");
|
||||
|
||||
describe("WebpackError", () => {
|
||||
class Foo {
|
||||
abstractMethod() {
|
||||
return new AbstractMethodError();
|
||||
}
|
||||
}
|
||||
|
||||
class Child extends Foo {}
|
||||
|
||||
const expectedMessage = "Abstract method $1. Must be overridden.";
|
||||
|
||||
it("Should construct message with caller info", () => {
|
||||
const fooClassError = new Foo().abstractMethod();
|
||||
const childClassError = new Child().abstractMethod();
|
||||
|
||||
expect(fooClassError.message).toBe(
|
||||
expectedMessage.replace("$1", "Foo.abstractMethod")
|
||||
);
|
||||
expect(childClassError.message).toBe(
|
||||
expectedMessage.replace("$1", "Child.abstractMethod")
|
||||
);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,6 @@
|
|||
it("should have [file] replaced with chunk filename in append", function() {
|
||||
var fs = require("fs"),
|
||||
path = require("path");
|
||||
var source = fs.readFileSync(path.join(__dirname, "some-test.js"), "utf-8");
|
||||
expect(source).toMatch("//# sourceMappingURL=http://localhost:50505/some-test.js.map");
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
var testObject = {
|
||||
a: 1
|
||||
};
|
||||
|
||||
module.exports = testObject;
|
|
@ -0,0 +1,28 @@
|
|||
var webpack = require("../../../../");
|
||||
var TerserPlugin = require("terser-webpack-plugin");
|
||||
module.exports = {
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false
|
||||
},
|
||||
entry: {
|
||||
bundle0: ["./index.js"],
|
||||
"some-test": ["./test.js"]
|
||||
},
|
||||
output: {
|
||||
filename: "[name].js"
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
sourceMap: true
|
||||
})
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.SourceMapDevToolPlugin({
|
||||
filename: "sourcemaps/[file].map",
|
||||
append: "\n//# sourceMappingURL=http://localhost:50505/[file].map"
|
||||
})
|
||||
]
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
module.exports = "wrong2-yes";
|
68
yarn.lock
68
yarn.lock
|
@ -624,9 +624,9 @@ ajv-keywords@^3.1.0:
|
|||
integrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==
|
||||
|
||||
ajv@^6.1.0, ajv@^6.5.5, ajv@^6.9.1:
|
||||
version "6.10.1"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.1.tgz#ebf8d3af22552df9dd049bfbe50cc2390e823593"
|
||||
integrity sha512-w1YQaVGNC6t2UCPjEawK/vo/dG8OOrVtUmhBT1uJJYxbl5kU2Tj3v6LGqBcsysN1yhuCStJCCA3GqdvKY8sqXQ==
|
||||
version "6.10.2"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52"
|
||||
integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==
|
||||
dependencies:
|
||||
fast-deep-equal "^2.0.1"
|
||||
fast-json-stable-stringify "^2.0.0"
|
||||
|
@ -1321,6 +1321,11 @@ commander@^2.14.1, commander@^2.19.0, commander@^2.9.0, commander@~2.20.0:
|
|||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
|
||||
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
|
||||
|
||||
comment-parser@^0.5.5:
|
||||
version "0.5.5"
|
||||
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-0.5.5.tgz#c2584cae7c2f0afc773e96b2ee98f8c10cbd693d"
|
||||
integrity sha512-oB3TinFT+PV3p8UwDQt71+HkG03+zwPwikDlKU6ZDmql6QX2zFlQ+G0GGSDqyJhdZi4PSlzFBm+YJ+ebOX3Vgw==
|
||||
|
||||
commondir@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
|
||||
|
@ -1411,12 +1416,12 @@ cosmiconfig@^5.0.7, cosmiconfig@^5.2.0:
|
|||
parse-json "^4.0.0"
|
||||
|
||||
coveralls@^3.0.2:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.4.tgz#f50233c9c62fd0973f710fce85fd19dba24cff4b"
|
||||
integrity sha512-eyqUWA/7RT0JagiL0tThVhjbIjoiEUyWCjtUJoOPcWoeofP5WK/jb2OJYoBFrR6DvplR+AxOyuBqk4JHkk5ykA==
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.5.tgz#28d7274c6c9827aa85537eab82d66e7e62d0d527"
|
||||
integrity sha512-/KD7PGfZv/tjKB6LoW97jzIgFqem0Tu9tZL9/iwBnBd8zkIZp7vT1ZSHNvnr0GSQMV/LTMxUstWg8WcDDUVQKg==
|
||||
dependencies:
|
||||
growl "~> 1.10.0"
|
||||
js-yaml "^3.11.0"
|
||||
js-yaml "^3.13.1"
|
||||
lcov-parse "^0.0.10"
|
||||
log-driver "^1.2.7"
|
||||
minimist "^1.2.0"
|
||||
|
@ -1836,9 +1841,21 @@ eslint-plugin-es@^1.3.1:
|
|||
regexpp "^2.0.1"
|
||||
|
||||
eslint-plugin-jest@^22.2.2:
|
||||
version "22.7.2"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.7.2.tgz#7ab118a66a34e46ae5e16a128b5d24fd28b43dca"
|
||||
integrity sha512-Aecqe3ulBVI7amgOycVI8ZPL8o0SnGHOf3zn2/Ciu8TXyXDHcjtwD3hOs3ss/Qh/VAwlW/DMcuiXg5btgF+XMA==
|
||||
version "22.8.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.8.0.tgz#242ef5459e8da25d2c41438e95eb546e03d7fae1"
|
||||
integrity sha512-2VftZMfILmlhL3VMq5ptHRIuyyXb3ShDEDb1J1UjvWNzm4l+UK/YmwNuTuJcM0gv8pJuOfiR/8ZptJ8Ou68pFw==
|
||||
|
||||
eslint-plugin-jsdoc@^15.3.2:
|
||||
version "15.5.2"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-15.5.2.tgz#89768320c64ec2f30d12209e1926c4decca0568a"
|
||||
integrity sha512-5s39RYGaqugWVoOfc6pAwj9yeNh7mclygBWTyYVJX+sGiNchwCtgHbn2AjeonOw0g168CPI3itiXetHj2Yo8gg==
|
||||
dependencies:
|
||||
comment-parser "^0.5.5"
|
||||
debug "^4.1.1"
|
||||
flat-map-polyfill "^0.3.8"
|
||||
jsdoctypeparser "5.0.1"
|
||||
lodash "^4.17.14"
|
||||
regextras "^0.6.1"
|
||||
|
||||
eslint-plugin-node@^8.0.0:
|
||||
version "8.0.1"
|
||||
|
@ -2219,6 +2236,11 @@ flat-cache@^2.0.1:
|
|||
rimraf "2.6.3"
|
||||
write "1.0.3"
|
||||
|
||||
flat-map-polyfill@^0.3.8:
|
||||
version "0.3.8"
|
||||
resolved "https://registry.yarnpkg.com/flat-map-polyfill/-/flat-map-polyfill-0.3.8.tgz#4ec0bfb7c70e2962f00db03548d3620471fd8697"
|
||||
integrity sha512-ZfmD5MnU7GglUEhiky9C7yEPaNq1/wh36RDohe+Xr3nJVdccwHbdTkFIYvetcdsoAckUKT51fuf44g7Ni5Doyg==
|
||||
|
||||
flatted@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.0.tgz#55122b6536ea496b4b44893ee2608141d10d9916"
|
||||
|
@ -3457,7 +3479,7 @@ js-tokens@^3.0.2:
|
|||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
|
||||
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=
|
||||
|
||||
js-yaml@3.x, js-yaml@^3.11.0, js-yaml@^3.12.0, js-yaml@^3.12.1, js-yaml@^3.13.0, js-yaml@^3.13.1:
|
||||
js-yaml@3.x, js-yaml@^3.12.0, js-yaml@^3.12.1, js-yaml@^3.13.0, js-yaml@^3.13.1:
|
||||
version "3.13.1"
|
||||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
|
||||
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
|
||||
|
@ -3470,6 +3492,11 @@ jsbn@~0.1.0:
|
|||
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
|
||||
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
|
||||
|
||||
jsdoctypeparser@5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/jsdoctypeparser/-/jsdoctypeparser-5.0.1.tgz#0d6bc09bb8bebeca5a588fcd508228d2189409a3"
|
||||
integrity sha512-dYwcK6TKzvq+ZKtbp4sbQSW9JMo6s+4YFfUs5D/K7bZsn3s1NhEhZ+jmIPzby0HbkbECBe+hNPEa6a+E21o94w==
|
||||
|
||||
jsdom@^11.5.1:
|
||||
version "11.12.0"
|
||||
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.12.0.tgz#1a80d40ddd378a1de59656e9e6dc5a3ba8657bc8"
|
||||
|
@ -3807,10 +3834,10 @@ lodash.sortby@^4.7.0:
|
|||
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
||||
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
|
||||
|
||||
lodash@^4.17.11, lodash@^4.17.4:
|
||||
version "4.17.11"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
|
||||
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
|
||||
lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.4:
|
||||
version "4.17.14"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
|
||||
integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==
|
||||
|
||||
log-driver@^1.2.7:
|
||||
version "1.2.7"
|
||||
|
@ -5160,6 +5187,11 @@ regexpp@^2.0.1:
|
|||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
|
||||
integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==
|
||||
|
||||
regextras@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/regextras/-/regextras-0.6.1.tgz#9689641bbb338e0ff7001a5c507c6a2008df7b36"
|
||||
integrity sha512-EzIHww9xV2Kpqx+corS/I7OBmf2rZ0pKKJPsw5Dc+l6Zq1TslDmtRIP9maVn3UH+72MIXmn8zzDgP07ihQogUA==
|
||||
|
||||
remove-trailing-separator@^1.0.1:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
|
||||
|
@ -5468,9 +5500,9 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
|
|||
integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=
|
||||
|
||||
simple-git@^1.65.0, simple-git@^1.85.0:
|
||||
version "1.118.0"
|
||||
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-1.118.0.tgz#6e31d50672c58abdbdb0410fadfdb1db29bd71bd"
|
||||
integrity sha512-0CaCfxdR7ula3EuOkrVFKBiqt7LcvMPfXgIdUhSwjC4A+OaO8yEPGjdO/kWY7ew9uYP9KEoH+dvslOOm7eVzkA==
|
||||
version "1.121.0"
|
||||
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-1.121.0.tgz#4bdf0828cd1b0bb3cb7ed9bead2771982ef5876a"
|
||||
integrity sha512-LyYri/nuAX8+cx9nZw38mWO6oHNi//CmiPlkBL7aVjZIsdldve7eeDwXu9L4wP/74MpNHucXkXc/BOuIQShhPg==
|
||||
dependencies:
|
||||
debug "^4.0.1"
|
||||
|
||||
|
|
Loading…
Reference in New Issue