Skip to content

Commit 8623343

Browse files
authored
fix: rename sourcemap flag to devtool (#1723)
1 parent 4a41faf commit 8623343

File tree

10 files changed

+9
-10
lines changed

10 files changed

+9
-10
lines changed

packages/webpack-cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ yarn add webpack-cli --dev
4949
-w, --watch Watch for files changes
5050
-h, --hot Enables Hot Module Replacement
5151
--no-hot Disables Hot Module Replacement
52-
-s, --sourcemap string Determine source maps to use
52+
-d, --devtool string Controls if and how source maps are generated.
5353
--prefetch string Prefetch this request
5454
-j, --json Prints result as JSON
5555
--mode string Defines the mode to pass to webpack

packages/webpack-cli/lib/groups/BasicGroup.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ class BasicGroup extends GroupHelper {
3030
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
3131
// this.opts.options.plugins = [new BundleAnalyzerPlugin()];
3232
// }
33-
if (arg === 'sourcemap') {
34-
options.devtool = args[arg] || 'eval';
35-
outputOptions.devtool = args[arg];
33+
if (arg === 'devtool') {
34+
options.devtool = args[arg];
3635
}
3736
if (arg === 'entry') {
3837
options[arg] = this.resolveFilePath(args[arg], 'index.js');

packages/webpack-cli/lib/utils/cli-flags.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let flagsFromCore =
3333
: [];
3434

3535
// duplicate flags
36-
const duplicateFlags = ['entry', 'mode', 'stats', 'watch', 'target'];
36+
const duplicateFlags = ['entry', 'mode', 'stats', 'watch', 'target', 'devtool'];
3737

3838
flagsFromCore = flagsFromCore.filter((flag) => !duplicateFlags.includes(flag.name));
3939

@@ -194,10 +194,10 @@ module.exports = {
194194
link: 'https://webpack.js.org/concepts/hot-module-replacement/',
195195
},
196196
{
197-
name: 'sourcemap',
198-
usage: '--sourcemap <sourcemap | eval>',
197+
name: 'devtool',
198+
usage: '--devtool <value>',
199199
type: String,
200-
alias: 's',
200+
alias: 'd',
201201
defaultValue: undefined,
202202
group: BASIC_GROUP,
203203
description: 'Determine source maps to use',

test/source-map/array/source-map-array.test.js renamed to test/devtool/array/source-map-array.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('source-map object', () => {
1414
});
1515
});
1616
it('should override entire array on flag', (done) => {
17-
const { stderr } = run(__dirname, ['--sourcemap', 'source-map', '--output', './binary'], false);
17+
const { stderr } = run(__dirname, ['--devtool', 'source-map', '--output', './binary'], false);
1818
expect(stderr).toBe('');
1919
readdir(resolve(__dirname, 'binary'), (err, files) => {
2020
expect(err).toBe(null);

test/source-map/object/source-map-object.test.js renamed to test/devtool/object/source-map-object.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('source-map object', () => {
2424
});
2525

2626
it('should override config with source-map', (done) => {
27-
run(__dirname, ['-c', './webpack.eval.config.js', '--sourcemap', 'source-map', '-o', './binary/dist-amd.js'], false);
27+
run(__dirname, ['-c', './webpack.eval.config.js', '--devtool', 'source-map', '-o', './binary/dist-amd.js'], false);
2828
stat(resolve(__dirname, 'binary/dist-amd.js.map'), (err, stats) => {
2929
expect(err).toBe(null);
3030
expect(stats.isFile()).toBe(true);
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)