Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename sourcemap flag to devtool #1723

Merged
merged 3 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
anshumanv marked this conversation as resolved.
Show resolved Hide resolved
// 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
6 changes: 3 additions & 3 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,8 +194,8 @@ 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',
anshumanv marked this conversation as resolved.
Show resolved Hide resolved
defaultValue: undefined,
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.
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