Skip to content

Commit

Permalink
fix: rename sourcemap flag to devtool (#1723)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv authored Aug 1, 2020
1 parent 4a41faf commit 8623343
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/webpack-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ yarn add webpack-cli --dev
-w, --watch Watch for files changes
-h, --hot Enables Hot Module Replacement
--no-hot Disables Hot Module Replacement
-s, --sourcemap string Determine source maps to use
-d, --devtool string Controls if and how source maps are generated.
--prefetch string Prefetch this request
-j, --json Prints result as JSON
--mode string Defines the mode to pass to webpack
Expand Down
5 changes: 2 additions & 3 deletions packages/webpack-cli/lib/groups/BasicGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class BasicGroup extends GroupHelper {
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
// this.opts.options.plugins = [new BundleAnalyzerPlugin()];
// }
if (arg === 'sourcemap') {
options.devtool = args[arg] || 'eval';
outputOptions.devtool = args[arg];
if (arg === 'devtool') {
options.devtool = args[arg];
}
if (arg === 'entry') {
options[arg] = this.resolveFilePath(args[arg], 'index.js');
Expand Down
8 changes: 4 additions & 4 deletions packages/webpack-cli/lib/utils/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let flagsFromCore =
: [];

// duplicate flags
const duplicateFlags = ['entry', 'mode', 'stats', 'watch', 'target'];
const duplicateFlags = ['entry', 'mode', 'stats', 'watch', 'target', 'devtool'];

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

Expand Down Expand Up @@ -194,10 +194,10 @@ module.exports = {
link: 'https://webpack.js.org/concepts/hot-module-replacement/',
},
{
name: 'sourcemap',
usage: '--sourcemap <sourcemap | eval>',
name: 'devtool',
usage: '--devtool <value>',
type: String,
alias: 's',
alias: 'd',
defaultValue: undefined,
group: BASIC_GROUP,
description: 'Determine source maps to use',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('source-map object', () => {
});
});
it('should override entire array on flag', (done) => {
const { stderr } = run(__dirname, ['--sourcemap', 'source-map', '--output', './binary'], false);
const { stderr } = run(__dirname, ['--devtool', 'source-map', '--output', './binary'], false);
expect(stderr).toBe('');
readdir(resolve(__dirname, 'binary'), (err, files) => {
expect(err).toBe(null);
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('source-map object', () => {
});

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

0 comments on commit 8623343

Please sign in to comment.