Skip to content

Commit ec2f9b0

Browse files
authored
Merge pull request #1 from webpack/master
20201114
2 parents 7b0aab3 + c593011 commit ec2f9b0

36 files changed

+1223
-835
lines changed

.github/workflows/testing.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Ensure PR
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest]
15+
node-version: [12.x]
16+
runs-on: ${{ matrix.os }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Get yarn cache directory path
26+
id: yarn-cache-dir-path
27+
run: echo "::set-output name=dir::$(yarn cache dir)"
28+
29+
- uses: actions/cache@v2
30+
id: yarn-cache
31+
with:
32+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
33+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-yarn-
36+
37+
- run: yarn --frozen-lockfile
38+
- run: yarn lint:js
39+
- run: yarn lint:markdown
40+
- run: yarn lint:social
41+
42+
proseLint:
43+
name: Proselint
44+
strategy:
45+
matrix:
46+
os: [ubuntu-latest]
47+
python-version: [3.6]
48+
runs-on: ${{ matrix.os }}
49+
steps:
50+
- uses: actions/checkout@v2
51+
52+
- name: Set up Python ${{ matrix.python-version }}
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: ${{ matrix.python-version }}
56+
- uses: actions/cache@v2
57+
with:
58+
path: ~/.cache/pip
59+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
60+
restore-keys: |
61+
${{ runner.os }}-pip-
62+
63+
- name: Install dependencies
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install -r requirements.txt
67+
68+
- run: cp .proselintrc ~/
69+
- run: proselint src/content
70+
71+
lintLinks:
72+
name: Check Links
73+
strategy:
74+
matrix:
75+
os: [ubuntu-latest]
76+
node-version: [12.x]
77+
runs-on: ${{ matrix.os }}
78+
steps:
79+
- uses: actions/checkout@v2
80+
81+
- name: Use Node.js ${{ matrix.node-version }}
82+
uses: actions/setup-node@v1
83+
with:
84+
node-version: ${{ matrix.node-version }}
85+
86+
- name: Get yarn cache directory path
87+
id: yarn-cache-dir-path
88+
run: echo "::set-output name=dir::$(yarn cache dir)"
89+
90+
- uses: actions/cache@v2
91+
id: yarn-cache
92+
with:
93+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
94+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
95+
restore-keys: |
96+
${{ runner.os }}-yarn-
97+
98+
- run: yarn
99+
- run: yarn build
100+
- run: yarn lint:links
101+
102+
e2e:
103+
name: End to End Testing
104+
strategy:
105+
matrix:
106+
os: [ubuntu-latest]
107+
node-version: [12.x]
108+
runs-on: ${{ matrix.os }}
109+
steps:
110+
- uses: actions/checkout@v2
111+
112+
- name: Use Node.js ${{ matrix.node-version }}
113+
uses: actions/setup-node@v1
114+
with:
115+
node-version: ${{ matrix.node-version }}
116+
117+
- name: Get yarn cache directory path
118+
id: yarn-cache-dir-path
119+
run: echo "::set-output name=dir::$(yarn cache dir)"
120+
121+
- uses: actions/cache@v2
122+
id: yarn-cache
123+
with:
124+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
125+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
126+
restore-keys: |
127+
${{ runner.os }}-yarn-
128+
129+
- run: |
130+
yarn
131+
yarn cypress install
132+
yarn cypress verify
133+
yarn fetch:supporters
134+
yarn fetch:starter-kits
135+
yarn cypress:ci

src/content/api/cli.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Command Line Interface
33
sort: 1
44
contributors:
55
- anshumanv
6+
- snitin315
67
- evenstensberg
78
- simon04
89
- tbroadley
@@ -61,10 +62,10 @@ Note: These are the flags with webpack v4, starting v5 CLI also supports [core f
6162
| `--no-color` | boolean | Disables colors on console |
6263
| `--merge, -m` | boolean | Merge two or more configurations using webpack-merge e.g. `-c ./webpack.config.js -c ./webpack.test.config.js` |
6364
| `--env` | string[] | Environment passed to the configuration when it is a function |
64-
| `--progress` | boolean | Print compilation progress during build |
65+
| `--progress` | boolean, string | Print compilation progress during build |
6566
| `--help` | boolean | Outputs list of supported flags and commands |
6667
| `--output-path, -o` | string | Output location of the file generated by webpack e.g. `./dist` |
67-
| `--target, -t` | string | Sets the build target |
68+
| `--target, -t` | string[] | Sets the build target |
6869
| `--watch, -w` | boolean | Watch for file changes |
6970
| `--hot, -h` | boolean | Enables Hot Module Replacement |
7071
| `--no-hot` | boolean | Disables Hot Module Replacement |
@@ -94,7 +95,7 @@ __Here's the list of all the core flags supported by webpack v5 with CLI v4 - [l
9495
For example if you want to enable performance hints in your project you'd use [this](https://webpack.js.org/configuration/performance/#performancehints) option in configuration, with core flags you can do -
9596

9697
```bash
97-
webpack --performance-hints warning`
98+
webpack --performance-hints warning
9899
```
99100

100101
## Usage
@@ -244,10 +245,11 @@ webpack --env production # sets env.production == true
244245

245246
The `--env` argument accepts multiple values:
246247

247-
| Invocation | Resulting environment |
248-
| ------------------------------ | --------------------------- |
249-
| `webpack --env prod` | `{ prod: true }` |
250-
| `webpack --env prod --env min` | `{ prod: true, min: true }` |
248+
| Invocation | Resulting environment |
249+
| --------------------------------------------- | --------------------------------------- |
250+
| `webpack --env prod` | `{ prod: true }` |
251+
| `webpack --env prod --env min` | `{ prod: true, min: true }` |
252+
| `webpack --env platform=app --env production` | `{ platform: "app", production: true }` |
251253

252254
T> See the [environment variables](/guides/environment-variables/) guide for more information on its usage.
253255

@@ -270,6 +272,20 @@ webpack --analyze
270272

271273
W> Make sure you have `webpack-bundle-analyzer` installed in your project else CLI will prompt you to install it.
272274

275+
## Progress
276+
277+
To check the progress of any webpack compilation you can use the `--progress` flag.
278+
279+
```bash
280+
webpack --progress
281+
```
282+
283+
To collect profile data for progress steps you can pass `profile` as value to `--progress` flag.
284+
285+
```bash
286+
webpack --progress=profile
287+
```
288+
273289
## Pass CLI arguments to Node.js
274290

275291
To pass arguments directly to Node.js process, you can use the `NODE_OPTIONS` option.
@@ -285,3 +301,11 @@ Also, you can pass multiple options to Node.js process
285301
```bash
286302
NODE_OPTIONS="--max-old-space-size=4096 -r /path/to/preload/file.js" webpack
287303
```
304+
305+
## Exit codes and their meanings
306+
307+
| Exit Code | Description |
308+
| --------- | -------------------------------------------------- |
309+
| `0` | Success |
310+
| `1` | Errors from webpack |
311+
| `2` | Configuration/options problem or an internal error |

src/content/api/loaders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ loadModule(request: string, callback: function(err, source, sourceMap, module))
390390

391391
Resolves the given request to a module, applies all configured loaders and calls back with the generated source, the sourceMap and the module instance (usually an instance of [`NormalModule`](https://github.com/webpack/webpack/blob/master/lib/NormalModule.js)). Use this function if you need to know the source code of another module to generate the result.
392392

393-
`this.loadModule` in a loader context uses CommonJS resolve rules by default. Use `this.getResolve` with an appropriate `dependencyType`, e. g. `'esm'`, `'commonjs'` or a custom one before using a different semantic.
393+
`this.loadModule` in a loader context uses CommonJS resolve rules by default. Use `this.getResolve` with an appropriate `dependencyType`, e.g. `'esm'`, `'commonjs'` or a custom one before using a different semantic.
394394

395395

396396
### `this.resolve`

src/content/api/resolvers.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ group: Plugins
44
sort: 13
55
contributors:
66
- EugeneHlushko
7+
- chenxsan
78
---
89

910
Resolvers are created using the `enhanced-resolve` package. The `Resolver`
@@ -28,17 +29,17 @@ Depending on need, any one of these built-in resolvers, that are used by the `co
2829
can be customized via plugins:
2930

3031
``` js
31-
compiler.resolverFactory.plugin('resolver [type]', resolver => {
32-
resolver.hooks.resolve.tapAsync('MyPlugin', params => {
33-
// ...
32+
compiler.resolverFactory.hooks.resolver.for('[type]').tap('name', resolver => {
33+
// you can tap into resolver.hooks now
34+
resolver.hooks.result.tap('MyPlugin', result => {
35+
return result;
3436
});
3537
});
3638
```
3739

3840
Where `[type]` is one of the three resolvers mentioned above.
3941

40-
See the [`enhanced-resolve` documentation](https://github.com/webpack/enhanced-resolve) for a full list of hooks and their
41-
description.
42+
See the [`enhanced-resolve` documentation](https://github.com/webpack/enhanced-resolve) for a full list of hooks and their description.
4243

4344

4445
## Configuration Options

src/content/api/stats.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ Each `assets` object represents an `output` file emitted from the compilation. T
8181
'immutable': true, // A flag telling whether the asset can be long term cached (contains a hash)
8282
'size': 1058, // The size in bytes, only becomes available after asset has been emitted
8383
'development': true, // A flag telling whether the asset is only used for development and doesn't count towards user-facing assets
84-
'hotModuleReplacement': true // A flag telling whether the asset ships data for updating an existing application (HMR)
84+
'hotModuleReplacement': true, // A flag telling whether the asset ships data for updating an existing application (HMR)
85+
'sourceFilename': 'originalfile.js', // sourceFilename when asset was created from a source file (potentially transformed)
86+
'javascriptModule': true // true, when asset is javascript and an ESM
8587
}
8688
}
8789
```

src/content/blog/2020-10-10-webpack-5-release.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Webpack 5 release (2020-10-10)
33
sort: -202010100
44
contributors:
55
- sokra
6+
- chenxsan
67
---
78

89
webpack 4 was released in February 2018.
@@ -167,7 +168,7 @@ __MIGRATION__: Use the default export.
167168

168169
Even when using the default export, unused properties are dropped by the `optimization.usedExports` optimization and properties are mangled by the `optimization.mangleExports` optimization.
169170

170-
It's possible to specify a custom JSON parser in `Rule.parser.parse` to import JSON-like files (e. g. for toml, yaml, json5, etc.).
171+
It's possible to specify a custom JSON parser in `Rule.parser.parse` to import JSON-like files (e.g. for toml, yaml, json5, etc.).
171172

172173
### import.meta
173174

@@ -474,7 +475,7 @@ The `target` option now influences more things about the generated code than bef
474475
- Some loaders might change behavior based on that
475476

476477
For some of these things the choice between `"web"` and `"node"` is too rough and we need more information.
477-
Therefore we allow to specify the minimum version e. g. like `"node10.13"` and infer more properties about the target environment.
478+
Therefore we allow to specify the minimum version e.g. like `"node10.13"` and infer more properties about the target environment.
478479

479480
It's now also allowed to combined multiple targets with an array and webpack will determine the minimum properties of all targets. Using an array is also useful when using targets that doesn't give full information like `"web"` or `"node"` (without version number). E. g. `["web", "es2020"]` combines these two partial targets.
480481

@@ -712,7 +713,7 @@ __MIGRATION__: Upgrade to the latest Node.js version available.
712713
- `output.chunkFilename: Function` is now allowed
713714
- `output.hotUpdateChunkFilename: Function` is now forbidden: It never worked anyway.
714715
- `output.hotUpdateMainFilename: Function` is now forbidden: It never worked anyway.
715-
- `output.importFunctionName: string` specifies the name used as replacement for `import()` to allow polyfilling for non-suppored environments
716+
- `output.importFunctionName: string` specifies the name used as replacement for `import()` to allow polyfilling for non-supported environments
716717
- `output.charset` added: setting it to false omit the `charset` property on script tags
717718
- `output.hotUpdateFunction` renamed to `output.hotUpdateGlobal`
718719
- `output.jsonpFunction` renamed to `output.chunkLoadingGlobal`
@@ -734,7 +735,7 @@ __MIGRATION__: Upgrade to the latest Node.js version available.
734735
- `stats.chunkRelations` added: Show parent/children/sibling chunks
735736
- `stats.errorStack` added: Show webpack-internal stack trace of errors
736737
- `stats.preset` added: select a preset
737-
- `stats.relatedAssets` added: show assets that are related to other assets (e. g. SourceMaps)
738+
- `stats.relatedAssets` added: show assets that are related to other assets (e.g. SourceMaps)
738739
- `stats.warningsFilter` deprecated in favor of `ignoreWarnings`
739740
- `BannerPlugin.banner` signature changed
740741
- `data.basename` removed
@@ -802,7 +803,7 @@ __MIGRATION__: This can be implemented in the loader itself
802803

803804
`getResolve(options)` in the loader API will merge options in a different way, see `module.rules` `resolve`.
804805

805-
As webpack 5 differs between different issuing dependencies so it might make sense to pass a `dependencyType` as option (e. g. `"esm"`, `"commonjs"`, or others).
806+
As webpack 5 differs between different issuing dependencies so it might make sense to pass a `dependencyType` as option (e.g. `"esm"`, `"commonjs"`, or others).
806807

807808
## Major Internal Changes
808809

@@ -1094,7 +1095,7 @@ __MIGRATION__: Instead of replacing the whole Stats functionality, you can now c
10941095

10951096
### New Watching
10961097

1097-
The watcher used by webpack was refactored. It was previously using `chokidar` and the native dependency `fsevents` (only on OSX). Now it's only based on native Node.js `fs`. This means there is no native dependency left in webpack.
1098+
The watcher used by webpack was refactored. It was previously using `chokidar` and the native dependency `fsevents` (only on macOS). Now it's only based on native Node.js `fs`. This means there is no native dependency left in webpack.
10981099

10991100
It also captures more information about filesystem while watching. It now captures mtimes and watches event times, as well as information about missing files. For this, the `WatchFileSystem` API changed a little bit. While on it we also converted Arrays to Sets and Objects to Maps.
11001101

@@ -1218,7 +1219,7 @@ These dependencies are cheaper to process and webpack uses them when possible
12181219

12191220
## Other Minor Changes
12201221

1221-
- removed buildin directory and replaced buildins with runtime modules
1222+
- removed builtin directory and replaced builtins with runtime modules
12221223
- Removed deprecated features
12231224
- BannerPlugin now only support one argument that can be an object, string or function
12241225
- removed `CachePlugin`
@@ -1393,7 +1394,7 @@ These dependencies are cheaper to process and webpack uses them when possible
13931394
- DependencyReference now takes a function to a module instead of a Module
13941395
- HarmonyImportSpecifierDependency.redirectedId removed
13951396
- __MIGRATION__: Use `setId` instead
1396-
- acorn 5 -> 7
1397+
- acorn 5 -> 8
13971398
- Testing
13981399
- HotTestCases now runs for multiple targets `async-node` `node` `web` `webworker`
13991400
- TestCases now also runs for filesystem caching with `store: "instant"` and `store: "pack"`
@@ -1405,7 +1406,7 @@ These dependencies are cheaper to process and webpack uses them when possible
14051406
- loader-runner was upgraded: https://github.com/webpack/loader-runner/releases/tag/v3.0.0
14061407
- `file/context/missingDependencies` in `Compilation` are no longer sorted for performance reasons
14071408
- Do not rely on the order
1408-
- webpack-sources was upgraded: https://github.com/webpack/webpack-sources/releases/tag/v2.0.0-beta.0
1409+
- webpack-sources was upgraded to version 2: https://github.com/webpack/webpack-sources/releases/tag/v2.0.1
14091410
- webpack-command support was removed
14101411
- Use schema-utils@2 for schema validation
14111412
- `Compiler.assetEmitted` has an improved second argument with more information
@@ -1428,4 +1429,4 @@ These dependencies are cheaper to process and webpack uses them when possible
14281429
- add `Compilation.deleteAsset` to correctly delete an assets and non-shared related assets
14291430
- expose `require("webpack-sources")` as `require("webpack").sources`
14301431
- terser 5
1431-
- Webpack can be written with an capital W when at the start of a sentence
1432+
- Webpack can be written with a capital W when at the start of a sentence

0 commit comments

Comments
 (0)