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

BREAKING: webpack-cli v3 #448

Merged
merged 75 commits into from
Jun 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ec6cc38
chore(monorepo): move to lerna
sendilkumarn Mar 18, 2018
bdafce0
chore(monorepo): use commands as normal instead of package
sendilkumarn Mar 18, 2018
3dd244b
fix(revert): packagejson
sendilkumarn Mar 18, 2018
059d6f9
chore(monorepo): prune files and update eslint rules
sendilkumarn Mar 18, 2018
8ef1804
chore(monorepo): fix the no-missing-require error
sendilkumarn Mar 18, 2018
a1d5406
chore(monorepo): fix typo
sendilkumarn Mar 18, 2018
a6a2715
chore(monorepo): fix typo
sendilkumarn Mar 18, 2018
e9bc6eb
Merge branch 'master' into lerna-workspace
sendilkumarn Mar 20, 2018
64cfef7
chore(monorepo): prune package json
sendilkumarn Mar 20, 2018
2738a1e
Merge branch 'next' into lerna-workspace
sendilkumarn Apr 4, 2018
d4c7c5d
chore(monorepo): merge package lock json
sendilkumarn Apr 4, 2018
ff6c371
chore(monorepo): updated package.json
sendilkumarn Apr 4, 2018
3c822cf
chore(monorepo): fix plugin package.json
sendilkumarn Apr 4, 2018
bdf7e5a
Merge pull request #353 from sendilkumarn/lerna-workspace
sendilkumarn Apr 15, 2018
fa452a0
chore(cli): move to lerna and scoped packages (#434)
evenstensberg May 14, 2018
b1a8398
chore(rebase): merge master branch
evenstensberg May 14, 2018
1db677e
chore(linting): resolve linter errors
evenstensberg May 14, 2018
a76c46f
chore(linting): fix linting errors
evenstensberg May 14, 2018
8f6f1db
chore(linting): resolve linting
evenstensberg May 14, 2018
80c9e9a
chore(linting): resolve linting
evenstensberg May 14, 2018
b2a7470
chore(scaffold): move addons to scaffold
evenstensberg May 14, 2018
df8287d
chore(scaffold): fix linting errors
evenstensberg May 14, 2018
f8a71c0
cli(prompt): initial comment for prompt file
evenstensberg May 14, 2018
5f357c9
cli(prompt): wip
evenstensberg May 14, 2018
74fb759
fix(monorepo): fix lint errors
sendilkumarn May 15, 2018
0fcc5b3
fix(monorepo): fix cross spawn versions
sendilkumarn May 15, 2018
ca8f5c1
fix(monorepo): update lock files
sendilkumarn May 15, 2018
2b3035c
fix(monorepo): fix versions in pacakges
sendilkumarn May 15, 2018
b02070d
chore(rebase): refactor stuff
evenstensberg May 17, 2018
b2c2bbd
cli(pkgs): re-add entries
evenstensberg May 17, 2018
ab38a3a
chore(v): revise pkg
evenstensberg May 17, 2018
faae7aa
v0.0.1
evenstensberg May 17, 2018
c36f3e8
chore(v): revise some deps
evenstensberg May 17, 2018
91be3fd
v0.0.2
evenstensberg May 17, 2018
b51e66d
v0.0.3
evenstensberg May 17, 2018
3ed29c6
chore(v): back to v1
evenstensberg May 17, 2018
6489b10
v0.0.2
evenstensberg May 17, 2018
01cef3f
v0.0.3
evenstensberg May 17, 2018
e29a173
v0.0.4
evenstensberg May 17, 2018
58a437d
chore(deps): update deps
evenstensberg May 17, 2018
bccc56e
chore(prompt): revise prompt cmd
evenstensberg May 17, 2018
062fa28
v0.0.5
evenstensberg May 17, 2018
7fca948
cli(path): resolve better
evenstensberg May 17, 2018
f544578
v0.0.6
evenstensberg May 17, 2018
ebe5c6b
chore(v.6): update init
evenstensberg May 17, 2018
3a82b7d
chore(pkg): v.6 on next
evenstensberg May 17, 2018
17c2c88
chore(monorepo): add bootstrap to run
sendilkumarn May 17, 2018
42468d3
chore(monorepo): fix appveyor build
sendilkumarn May 17, 2018
a08b899
chore(monorepo): fix appveyor build
sendilkumarn May 18, 2018
ae55183
chore(monorepo): add eslint-plugin-prettier
sendilkumarn May 18, 2018
206749b
chore(monorepo): fix appveyor build
sendilkumarn May 17, 2018
7de58ea
chore(monorepo): fix versions and use clean bootstrap
sendilkumarn May 18, 2018
7c0e245
chore(monorepo): add rimraf globally
sendilkumarn May 18, 2018
2be0bce
Merge branch 'next' of https://github.com/webpack/webpack-cli into next
evenstensberg May 19, 2018
8c58d24
chore(monorepo): fix windows build
sendilkumarn May 19, 2018
e87fd7d
cli(color): don't use color on non-tty (#452)
evenstensberg May 20, 2018
0989b1d
Added yarn lock file to gitignore (#455)
nveenjain May 20, 2018
78b48a6
chore(next): dev version bump
evenstensberg May 21, 2018
0310fd3
chore(monorepo): fix windows build
sendilkumarn May 21, 2018
217670f
cli(symlinks): Fix paths (#453)
evenstensberg May 21, 2018
8e48e37
cli(init): Better defaults (#451)
evenstensberg May 22, 2018
92816e1
fix(vulnerabilities): vulnerabilities patch for v3 (#460)
dhruvdutt May 24, 2018
3dc8458
tests(parser): fix recursive-tests signature (#470)
dhruvdutt May 30, 2018
0c9b942
chore(rebase): rebase against master
evenstensberg May 31, 2018
4153395
Merge branch 'master' of https://github.com/webpack/webpack-cli into …
evenstensberg May 31, 2018
a7d8085
chore(deps): add lerna
evenstensberg Jun 1, 2018
49ec223
tests(coverage): fix coverage (#473)
evenstensberg Jun 1, 2018
3aa96ce
tests(cov): use regular nyc on tests
evenstensberg Jun 1, 2018
467c217
Merge branch 'master' into next
evenstensberg Jun 1, 2018
0b024bf
chore(lockfile): update pkglock
evenstensberg Jun 1, 2018
372a90e
chore(semantic): configure plugins (#475)
evenstensberg Jun 2, 2018
9475b17
fix(cli): show help flag when defaults fail (#466)
sumit-gupta91 Jun 2, 2018
7be10d8
tests(no-options): refactor tests
evenstensberg Jun 2, 2018
7490caa
ast(parser): add (#456)
dhruvdutt Jun 2, 2018
bf78411
cli(add): re-add add command
evenstensberg Jun 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build: off
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm i -g npm
- npm i
- npm ci
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we facing issues with npm ci? Also, if we're doing npm i then we probably don't need to run npm ci.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just people not updating package-locks, it's a safeguard.

- npm install --global codecov
- npm install eslint-plugin-node@latest --save-dev
Expand Down
32 changes: 30 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ module.exports = {
"node/no-missing-require": [
"error",
{
"resolvePaths": ["./packages"],
"allowModules": [
"webpack"
"webpack",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
Expand All @@ -71,7 +79,27 @@ module.exports = {
{
"allowModules": [
"webpack",
"webpack-dev-server"
"webpack-dev-server",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
"node/no-extraneous-require": [
"error",
{
"allowModules": [
"@webpack-cli/migrate",
"@webpack-cli/generators",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
Expand Down
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ npm-debug.*
yarn-error.log

# Jest Coverage
/coverage
/.nyc_output
coverage
.nyc_output

# Test Compilation
test/js/*

# lerna log
lerna-debug.log

# Yeoman file
.yo-rc.json
.yo-rc.json

# Yarn lock file
yarn.lock
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ notifications:
email: false
language: node_js
node_js:
- "10"
- "8"
- "7"
- "6"
Expand Down Expand Up @@ -49,6 +50,7 @@ install:
- npm install -g codecov
- npm install -g eslint
- npm install -g greenkeeper-lockfile@1
- lerna bootstrap

before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
Expand All @@ -60,4 +62,6 @@ jobs:
- stage: NPM release
if: branch = master
node_js: "lts/*"
script: npm run travis-deploy-once "npm run semantic-release"
script:
- npm run changelog
- npm run travis-deploy-once "npm run semantic-release"
10 changes: 1 addition & 9 deletions INIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ What we are meaning here, is if you want to provide your bundle a single or mult

This answers to the output directory of your application. The output directory is where servers or your `index.html` will read the generated bundle from.

3. `Are you going to use this in production? (Y/n)`

If you answer `Yes` to this, we add [`MinCssExtractPlugin`](https://github.com/webpack-contrib/mini-css-extract-plugin) to your project. This means that your style files will be separated in production from the bundles where they are used. If you answer `No`, we will not use the plugin, and `Question 6` will be ignored by default.

4. `Will you be using ES2015? (Y/n)`

If you answer `Yes` to this question, we will add [`ES2015`](https://babeljs.io/learn-es2015/) to your webpack configuration, which will allow you to use modern JavaScript in your project.
Expand All @@ -29,8 +25,4 @@ If you use any sort of style in your project, such as [`.less`](http://lesscss.o
6. `If you want to bundle your CSS files, what will you name the bundle? (press
enter to skip)`

If you answered `Yes` to `Question 3`, this will be enabled. The default value for your generated CSS file is `style.[contentHash].css`, which will collect all your `.less`, `.scss` or `.css` into one file. This will make your build faster in production.

7. `Name your 'webpack.[name].js?' [default: 'prod/config']`

If you answered `Yes` to `Question 3`, the default name of your configuration will be `webpack.prod.js`, otherwise it will be `webpack.config.js` if you don't answer. Other good options to answer to this question is: `dev`, `base`, `production` or `development`.
If you indicate based on previous questions that you are using production, this will be enabled. The default value for your generated CSS file is `style.[contentHash].css`, which will collect all your `.less`, `.scss` or `.css` into one file. This will make your build faster in production.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The `migrate` feature eases the transition from [version 1](http://webpack.githu

The `init` feature allows users to get started with webpack, fast. Through scaffolding, people can create their own configuration in order to faster initialize new projects for various of use cases.

`webpack-cli init webpack-addons-<package>`
`webpack-cli init webpack-scaffold-<package>`

[Read more about scaffolding](SCAFFOLDING.md)

Expand Down
12 changes: 6 additions & 6 deletions SCAFFOLDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Before writing a `webpack-cli` scaffold, think about what you're trying to achie

`webpack-cli` offers an experience that is interactive and you can prompt users for questions (like, "What is your entry point?") to help customize the output accordingly.

## webpack-addons
## webpack-scaffold
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have webpack-scaffold npm name right?

Have you got one already?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's scoped, so it's ours, right?


[`webpack-addons`](https://github.com/webpack-contrib/webpack-addons) is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself.
`webpack-scaffold` is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself.

## webpack-addons-yourpackage
## webpack-scaffold-yourpackage

In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `addon`, please read [How do I compose a
webpack-addon?](https://github.com/ev1stensberg/webpack-addons-demo).
In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `scaffold`, please read [How do I compose a
webpack-addon?](https://github.com/ev1stensberg/webpack-scaffold-demo).

If the package is on npm, its name must have a prefix of `webpack-addons`.
If the package is on npm, its name must have a prefix of `webpack-scaffold`.

If the package is on your local filesystem, it can be named whatever you want. Pass the path to the package.

Expand Down
43 changes: 34 additions & 9 deletions bin/webpack.js → bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@
}

require("v8-compile-cache");

// try local module, fallback to global
try {
require.resolve("webpack");
process.webpackModule = require("webpack");
} catch (err) {
const globalPathToWebpack = require("global-modules-path").getPath(
"webpack"
);
process.webpackModule = require(globalPathToWebpack);
}
const ErrorHelpers = require("./errorHelpers");

const NON_COMPILATION_ARGS = [
"init",
"migrate",
/*
"add",
/*
"remove",
"update",
"make",
Expand All @@ -41,9 +52,7 @@
});

if (NON_COMPILATION_CMD) {
// eslint-disable-next-line
require("../lib/index")(NON_COMPILATION_CMD, process.argv);
return;
return require("./prompt-command")(NON_COMPILATION_CMD, ...process.argv);
}

const yargs = require("yargs").usage(`webpack-cli ${
Expand Down Expand Up @@ -81,7 +90,9 @@ For more information, see https://webpack.js.org/api/cli/.`);
type: "boolean",
alias: "colors",
default: function supportsColor() {
return require("supports-color").supportsColor;
if (process.stdout.isTTY === true) {
return require("supports-color").supportsColor;
}
},
group: DISPLAY_GROUP,
describe: "Enables/Disables colors on the console"
Expand Down Expand Up @@ -287,7 +298,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
}

const firstOptions = [].concat(options)[0];
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
const statsPresetToOptions = process.webpackModule.Stats.presetToOptions;

let outputOptions = options.stats;
if (
Expand Down Expand Up @@ -323,7 +334,10 @@ For more information, see https://webpack.js.org/api/cli/.`);
}
});

if (typeof outputOptions.colors === "undefined")
if (
typeof outputOptions.colors === "undefined" &&
process.stdout.isTTY === true
)
outputOptions.colors = require("supports-color").stdout;

ifArg("sort-modules-by", function(value) {
Expand Down Expand Up @@ -429,7 +443,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
outputOptions.buildDelimiter = value;
});

const webpack = require("webpack");
const webpack = process.webpackModule;

let lastHash = null;
let compiler;
Expand All @@ -450,7 +464,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
}

if (argv.progress) {
const ProgressPlugin = require("webpack").ProgressPlugin;
const ProgressPlugin = process.webpackModule.ProgressPlugin;
new ProgressPlugin({
profile: argv.profile
}).apply(compiler);
Expand Down Expand Up @@ -482,6 +496,17 @@ For more information, see https://webpack.js.org/api/cli/.`);
);
} else if (stats.hash !== lastHash) {
lastHash = stats.hash;
if (stats.compilation && stats.compilation.errors.length !== 0) {
const errors = stats.compilation.errors;
if (errors[0].name === "EntryModuleNotFoundError") {
console.error(
"\n\u001b[1m\u001b[31mInsufficient number of arguments or no entry found."
);
console.error(
"\u001b[1m\u001b[31mAlternatively, run 'webpack(-cli) --help' for usage info.\u001b[39m\u001b[22m\n"
);
}
}
const statsString = stats.toString(outputOptions);
const delimiter = outputOptions.buildDelimiter
? `${outputOptions.buildDelimiter}\n`
Expand Down
2 changes: 1 addition & 1 deletion bin/config-yargs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const optionsSchema = require("webpack/schemas/WebpackOptions.json");
const optionsSchema = require("./optionsSchema.json");
const CONFIG_GROUP = "Config options:";
const BASIC_GROUP = "Basic options:";
const MODULE_GROUP = "Module options:";
Expand Down
29 changes: 15 additions & 14 deletions bin/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const fs = require("fs");
fs.existsSync = fs.existsSync || path.existsSync;
const interpret = require("interpret");
const prepareOptions = require("./prepareOptions");
const webpackConfigurationSchema = require("../schemas/webpackConfigurationSchema.json");
const validateSchema = require("webpack").validateSchema;
const WebpackOptionsValidationError = require("webpack")
.WebpackOptionsValidationError;
const webpackConfigurationSchema = require("./webpackConfigurationSchema.json");
const validateSchema = process.webpackModule.validateSchema;
const WebpackOptionsValidationError =
process.webpackModule.WebpackOptionsValidationError;

module.exports = function(...args) {
const argv = args[1] || args[0];
Expand Down Expand Up @@ -398,7 +398,7 @@ module.exports = function(...args) {
defineObject = {};
},
function() {
const DefinePlugin = require("webpack").DefinePlugin;
const DefinePlugin = process.webpackModule.DefinePlugin;
addPlugin(options, new DefinePlugin(defineObject));
}
);
Expand Down Expand Up @@ -468,13 +468,13 @@ module.exports = function(...args) {
mapArgToBoolean("cache");

ifBooleanArg("hot", function() {
const HotModuleReplacementPlugin = require("webpack")
.HotModuleReplacementPlugin;
const HotModuleReplacementPlugin =
process.webpackModule.HotModuleReplacementPlugin;
addPlugin(options, new HotModuleReplacementPlugin());
});

ifBooleanArg("debug", function() {
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
addPlugin(
options,
new LoaderOptionsPlugin({
Expand Down Expand Up @@ -510,8 +510,8 @@ module.exports = function(...args) {
});

ifArg("optimize-max-chunks", function(value) {
const LimitChunkCountPlugin = require("webpack").optimize
.LimitChunkCountPlugin;
const LimitChunkCountPlugin =
process.webpackModule.optimize.LimitChunkCountPlugin;
addPlugin(
options,
new LimitChunkCountPlugin({
Expand All @@ -521,7 +521,8 @@ module.exports = function(...args) {
});

ifArg("optimize-min-chunk-size", function(value) {
const MinChunkSizePlugin = require("webpack").optimize.MinChunkSizePlugin;
const MinChunkSizePlugin =
process.webpackModule.optimize.MinChunkSizePlugin;
addPlugin(
options,
new MinChunkSizePlugin({
Expand All @@ -531,7 +532,7 @@ module.exports = function(...args) {
});

ifBooleanArg("optimize-minimize", function() {
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
addPlugin(
options,
new LoaderOptionsPlugin({
Expand All @@ -541,7 +542,7 @@ module.exports = function(...args) {
});

ifArg("prefetch", function(request) {
const PrefetchPlugin = require("webpack").PrefetchPlugin;
const PrefetchPlugin = process.webpackModule.PrefetchPlugin;
addPlugin(options, new PrefetchPlugin(request));
});

Expand All @@ -554,7 +555,7 @@ module.exports = function(...args) {
} else {
name = value;
}
const ProvidePlugin = require("webpack").ProvidePlugin;
const ProvidePlugin = process.webpackModule.ProvidePlugin;
addPlugin(options, new ProvidePlugin(name, value));
});

Expand Down
Loading