Remove devtoolLineToLine and lineToLine options

This commit is contained in:
Florent Cailhol 2018-11-12 08:09:51 +01:00
parent 8a10ea3c92
commit caefde17ab
14 changed files with 0 additions and 285 deletions

View File

@ -1062,14 +1062,6 @@ export interface OutputOptions {
* Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers.
*/
devtoolFallbackModuleFilenameTemplate?: string | Function;
/**
* Enable line to line mapped mode for all/specified modules. Line to line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source. Its a performance optimization. Only use it if your performance need to be better and you are sure that input lines match which generated lines.
*/
devtoolLineToLine?:
| boolean
| {
[k: string]: any;
};
/**
* Filename template string of function for the sources array in a generated SourceMap.
*/

View File

@ -44,25 +44,6 @@ export interface SourceMapDevToolPluginOptions {
* Include source maps for module paths that match the given value
*/
include?: Rules;
/**
* (deprecated) try to map original files line to line to generated files
*/
lineToLine?:
| boolean
| {
/**
* Exclude modules that match the given value from source map generation
*/
exclude?: Rules;
/**
* Include source maps for module paths that match the given value
*/
include?: Rules;
/**
* Include source maps for modules based on their extension (defaults to .js and .css)
*/
test?: Rules;
};
/**
* Indicates whether SourceMaps from loaders should be used (defaults to true)
*/

View File

@ -103,7 +103,6 @@ class Module extends DependenciesBlock {
// TODO refactor this -> options object filled from Factory
this.useSourceMap = false;
this.lineToLine = false;
// TODO figure out if this should be defined here instead of `NormalModule`.
// Without this, type checking fails because the hooks use `Module`.

View File

@ -9,7 +9,6 @@ const { getContext, runLoaders } = require("loader-runner");
const asyncLib = require("neo-async");
const {
CachedSource,
LineToLineMappedSource,
OriginalSource,
RawSource,
SourceMapSource
@ -263,14 +262,6 @@ class NormalModule extends Module {
// from here on we assume we have an identifier
const identifier = this.identifier();
if (this.lineToLine && resourceBuffer) {
return new LineToLineMappedSource(
source,
identifier,
asString(resourceBuffer)
);
}
if (this.useSourceMap && sourceMap) {
return new SourceMapSource(source, identifier, sourceMap);
}
@ -654,7 +645,6 @@ class NormalModule extends Module {
write(this._source);
write(this._buildHash);
write(this.buildTimestamp);
write(this.lineToLine);
write(this.error);
write(this._cachedSources);
write(this._lastSuccessfulBuildMeta);
@ -686,7 +676,6 @@ class NormalModule extends Module {
this._source = read();
this._buildHash = read();
this.buildTimestamp = read();
this.lineToLine = read();
this.error = read();
this._cachedSources = read();
this._lastSuccessfulBuildMeta = read();

View File

@ -5,8 +5,6 @@
"use strict";
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
/** @typedef {import("./Compilation")} Compilation */
class SourceMapDevToolModuleOptionsPlugin {
@ -28,28 +26,6 @@ class SourceMapDevToolModuleOptionsPlugin {
}
);
}
if (options.lineToLine === true) {
compilation.hooks.buildModule.tap(
"SourceMapDevToolModuleOptionsPlugin",
module => {
module.lineToLine = true;
}
);
} else if (options.lineToLine) {
compilation.hooks.buildModule.tap(
"SourceMapDevToolModuleOptionsPlugin",
module => {
if (!module.resource) return;
let resourcePath = module.resource;
const idx = resourcePath.indexOf("?");
if (idx >= 0) resourcePath = resourcePath.substr(0, idx);
module.lineToLine = ModuleFilenameHelpers.matchObject(
options.lineToLine,
resourcePath
);
}
);
}
}
}

View File

@ -282,7 +282,6 @@ class WebpackOptionsApply extends OptionsApply {
append: hidden ? false : comment,
module: moduleMaps ? true : cheap ? false : true,
columns: cheap ? false : true,
lineToLine: options.output.devtoolLineToLine,
noSources: noSources,
namespace: options.output.devtoolNamespace
}).apply(compiler);

View File

@ -193,7 +193,6 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("output.hashFunction", "md4");
this.set("output.hashDigest", "hex");
this.set("output.hashDigestLength", 20);
this.set("output.devtoolLineToLine", false);
this.set("output.strictModuleExceptionHandling", false);
this.set("node", "call", value => {

View File

@ -872,19 +872,6 @@
}
]
},
"devtoolLineToLine": {
"description": "Enable line to line mapped mode for all/specified modules. Line to line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source. Its a performance optimization. Only use it if your performance need to be better and you are sure that input lines match which generated lines.",
"anyOf": [
{
"description": "`true` enables it for all modules (not recommended)",
"type": "boolean"
},
{
"description": "An object similar to `module.loaders` enables it for specific files.",
"type": "object"
}
]
},
"devtoolModuleFilenameTemplate": {
"description": "Filename template string of function for the sources array in a generated SourceMap.",
"anyOf": [

View File

@ -100,45 +100,6 @@
}
]
},
"lineToLine": {
"description": "(deprecated) try to map original files line to line to generated files",
"anyOf": [
{
"type": "boolean"
},
{
"description": "Simplify and speed up source mapping by using line to line source mappings for matched modules",
"type": "object",
"additionalProperties": false,
"properties": {
"exclude": {
"description": "Exclude modules that match the given value from source map generation",
"anyOf": [
{
"$ref": "#/definitions/rules"
}
]
},
"include": {
"description": "Include source maps for module paths that match the given value",
"anyOf": [
{
"$ref": "#/definitions/rules"
}
]
},
"test": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css)",
"anyOf": [
{
"$ref": "#/definitions/rules"
}
]
}
}
}
]
},
"module": {
"description": "Indicates whether SourceMaps from loaders should be used (defaults to true)",
"type": "boolean"

View File

@ -1,145 +0,0 @@
"use strict";
const SourceMapDevToolModuleOptionsPlugin = require("../lib/SourceMapDevToolModuleOptionsPlugin");
const applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
describe("SourceMapDevToolModuleOptionsPlugin", () => {
describe("when applied", () => {
let eventBindings;
beforeEach(() => {
eventBindings = undefined;
});
describe("with module false and line-to-line false", () => {
beforeEach(() => {
eventBindings = applyPluginWithOptions(
SourceMapDevToolModuleOptionsPlugin,
{
module: false,
lineToLine: false
}
);
});
it("does not bind any event handlers", () => {
expect(eventBindings.length).toBe(0);
});
});
describe("with module true", () => {
beforeEach(() => {
eventBindings = applyPluginWithOptions(
SourceMapDevToolModuleOptionsPlugin,
{
module: true,
lineToLine: false
}
);
});
it("binds one event handler", () => {
expect(eventBindings.length).toBe(1);
});
describe("event handler", () => {
it("binds to build-module event", () => {
expect(eventBindings[0].name).toBe("build-module");
});
it("sets source map flag", () => {
const module = {};
eventBindings[0].handler(module);
expect(module).toEqual({
useSourceMap: true
});
});
});
});
describe("with line-to-line true", () => {
beforeEach(() =>
(eventBindings = applyPluginWithOptions(
SourceMapDevToolModuleOptionsPlugin,
{
module: false,
lineToLine: true
}
)));
it("binds one event handler", () => {
expect(eventBindings.length).toBe(1);
});
describe("event handler", () => {
it("binds to build-module event", () => {
expect(eventBindings[0].name).toBe("build-module");
});
it("sets line-to-line flag", () => {
const module = {};
eventBindings[0].handler(module);
expect(module).toEqual({
lineToLine: true
});
});
});
});
describe("with line-to-line object", () => {
beforeEach(() => {
eventBindings = applyPluginWithOptions(
SourceMapDevToolModuleOptionsPlugin,
{
module: false,
lineToLine: {}
}
);
});
it("binds one event handler", () => {
expect(eventBindings.length).toBe(1);
});
describe("event handler", () => {
it("binds to build-module event", () => {
expect(eventBindings[0].name).toBe("build-module");
});
describe("when module has no resource", () => {
it("makes no changes", () => {
const module = {};
eventBindings[0].handler(module);
expect(module).toEqual({});
});
});
describe("when module has a resource", () => {
it("sets line-to-line flag", () => {
const module = {
resource: "foo"
};
eventBindings[0].handler(module);
expect(module).toEqual({
lineToLine: true,
resource: "foo"
});
});
});
describe("when module has a resource with query", () => {
it("sets line-to-line flag", () => {
const module = {
resource: "foo?bar"
};
eventBindings[0].handler(module);
expect(module).toEqual({
lineToLine: true,
resource: "foo?bar"
});
});
});
});
});
});
});

View File

@ -1,7 +1,6 @@
module.exports = {
mode: "development",
output: {
devtoolLineToLine: true,
devtoolModuleFilenameTemplate: function(info) {
return "dummy:///" + info.resourcePath;
}

View File

@ -1,8 +0,0 @@
it("should include test.js in SourceMap", function() {
var fs = require("fs");
var source = fs.readFileSync(__filename + ".map", "utf-8");
var map = JSON.parse(source);
expect(map.sources).toContain("webpack:///./test.js");
});
require.include("./test.js");

View File

@ -1,3 +0,0 @@
var foo = {};
module.exports = foo;

View File

@ -1,11 +0,0 @@
module.exports = {
mode: "development",
output: {
devtoolLineToLine: true
},
node: {
__dirname: false,
__filename: false
},
devtool: "cheap-source-map"
};