Merge pull request #14628 from artonge/patch-1

Fix separation token in identifier split.
This commit is contained in:
Tobias Koppers 2022-01-10 13:46:18 +01:00 committed by GitHub
commit f1833b113f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 2 deletions

View File

@ -5,6 +5,7 @@
"use strict";
const NormalModule = require("./NormalModule");
const createHash = require("./util/createHash");
const memoize = require("./util/memoize");
@ -138,7 +139,10 @@ ModuleFilenameHelpers.createFilename = (
);
identifier = memoize(() => requestShortener.shorten(module.identifier()));
moduleId = () => chunkGraph.getModuleId(module);
absoluteResourcePath = () => module.identifier().split("!").pop();
absoluteResourcePath = () =>
module instanceof NormalModule
? module.resource
: module.identifier().split("!").pop();
hash = getHash(identifier, hashFunction);
}
const resource = memoize(() => shortIdentifier().split("!").pop());

View File

@ -246,4 +246,4 @@
"json"
]
}
}
}

View File

@ -0,0 +1,14 @@
it("should not include layer or type in absoluteResourcePath", function () {
var fs = require("fs");
var path = require("path");
var source = fs.readFileSync(__filename + ".map", "utf-8");
var map = JSON.parse(source);
expect(map.sources).toContain(
path.resolve(
__dirname,
"../../../..//configCases/source-map/resource-path/test.js"
)
);
});
if (Math.random() < 0) require("./test.js");

View File

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

View File

@ -0,0 +1,22 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
node: {
__dirname: false,
__filename: false
},
experiments: {
layers: true
},
devtool: "source-map",
entry: {
main: {
import: "./index",
layer: "something"
}
},
output: {
devtoolModuleFilenameTemplate(info) {
return info.absoluteResourcePath;
}
}
};