Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17331 from webpack/issue-16415
fix: do not add `js` extension for eval source maps
- Loading branch information
Showing
10 changed files
with
207 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/configCases/devtools/eval-nosources-source-map/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
it("should not include sourcesContent if noSources option is used", function() { | ||
var fs = require("fs"); | ||
var source = fs.readFileSync(__filename, "utf-8"); | ||
var match = /\/\/# sourceMappingURL\s*=\s*data:application\/json;charset=utf-8;base64,(.*)\\n\/\/#/.exec(source); | ||
var mapString = Buffer.from(match[1], 'base64').toString('utf-8'); | ||
var map = JSON.parse(mapString); | ||
expect(map).not.toHaveProperty("sourcesContent"); | ||
expect(/\.ts(\?.+)?$/.test(map.file)).toBe(true); | ||
}); | ||
|
||
if (Math.random() < 0) require("./test.js"); |
1 change: 1 addition & 0 deletions
1
test/configCases/devtools/eval-nosources-source-map/node_modules/pkg/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
87 changes: 83 additions & 4 deletions
87
test/configCases/devtools/eval-nosources-source-map/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,83 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
devtool: "eval-nosources-source-map" | ||
}; | ||
const devtool = "eval-nosources-source-map"; | ||
|
||
/** @type {import("../../../../").Configuration[]} */ | ||
module.exports = [ | ||
{ | ||
devtool | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "natural" | ||
} | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "deterministic" | ||
} | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "size" | ||
} | ||
}, | ||
{ | ||
entry: "./index?foo=bar", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
entry: "./index.js?foo=bar", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
entry: "alias", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
}, | ||
resolve: { | ||
alias: { | ||
alias: "./index?foo=bar" | ||
} | ||
} | ||
}, | ||
{ | ||
entry: "pkg", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
entry: "./index.ts?foo=bar", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
loader: "ts-loader", | ||
options: { | ||
transpileOnly: true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
it("should not include sourcesContent if noSources option is used", function() { | ||
var fs = require("fs"); | ||
var source = fs.readFileSync(__filename, "utf-8"); | ||
var match = /\/\/# sourceMappingURL\s*=\s*data:application\/json;charset=utf-8;base64,(.*)\\n\/\/#/.exec(source); | ||
var mapString = Buffer.from(match[1], 'base64').toString('utf-8'); | ||
var map = JSON.parse(mapString); | ||
expect(map).toHaveProperty("sourcesContent"); | ||
expect(/\.js(\?.+)?$/.test(map.file)).toBe(true); | ||
}); | ||
|
||
if (Math.random() < 0) require("./test.js"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
it("should not include sourcesContent if noSources option is used", function() { | ||
var fs = require("fs"); | ||
var source = fs.readFileSync(__filename, "utf-8"); | ||
var match = /\/\/# sourceMappingURL\s*=\s*data:application\/json;charset=utf-8;base64,(.*)\\n\/\/#/.exec(source); | ||
var mapString = Buffer.from(match[1], 'base64').toString('utf-8'); | ||
var map = JSON.parse(mapString); | ||
expect(map).toHaveProperty("sourcesContent"); | ||
expect(/\.ts(\?.+)?$/.test(map.file)).toBe(true); | ||
}); | ||
|
||
if (Math.random() < 0) require("./test.js"); |
1 change: 1 addition & 0 deletions
1
test/configCases/devtools/eval-source-map/node_modules/pkg/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var foo = {}; | ||
|
||
module.exports = foo; |
83 changes: 83 additions & 0 deletions
83
test/configCases/devtools/eval-source-map/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
const devtool = "eval-source-map"; | ||
|
||
/** @type {import("../../../../").Configuration[]} */ | ||
module.exports = [ | ||
{ | ||
devtool | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "natural" | ||
} | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "deterministic" | ||
} | ||
}, | ||
{ | ||
devtool, | ||
optimization: { | ||
moduleIds: "size" | ||
} | ||
}, | ||
{ | ||
entry: "./index?foo=bar", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
entry: "./index.js?foo=bar", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
entry: "alias", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
}, | ||
resolve: { | ||
alias: { | ||
alias: "./index?foo=bar" | ||
} | ||
} | ||
}, | ||
{ | ||
entry: "pkg", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}, | ||
{ | ||
entry: "./index.ts?foo=bar", | ||
devtool, | ||
optimization: { | ||
moduleIds: "named" | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
loader: "ts-loader", | ||
options: { | ||
transpileOnly: true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
]; |