Skip to content

Commit

Permalink
Merge pull request #1 from webpack/master
Browse files Browse the repository at this point in the history
20201114
  • Loading branch information
xp44mm authored Nov 14, 2020
2 parents 7b0aab3 + c593011 commit ec2f9b0
Show file tree
Hide file tree
Showing 36 changed files with 1,223 additions and 835 deletions.
135 changes: 135 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Ensure PR

on:
push:
branches-ignore:
- master
pull_request:

jobs:
lint:
name: Lint
strategy:
matrix:
os: [ubuntu-latest]
node-version: [12.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --frozen-lockfile
- run: yarn lint:js
- run: yarn lint:markdown
- run: yarn lint:social

proseLint:
name: Proselint
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.6]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- run: cp .proselintrc ~/
- run: proselint src/content

lintLinks:
name: Check Links
strategy:
matrix:
os: [ubuntu-latest]
node-version: [12.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn
- run: yarn build
- run: yarn lint:links

e2e:
name: End to End Testing
strategy:
matrix:
os: [ubuntu-latest]
node-version: [12.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: |
yarn
yarn cypress install
yarn cypress verify
yarn fetch:supporters
yarn fetch:starter-kits
yarn cypress:ci
38 changes: 31 additions & 7 deletions src/content/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Command Line Interface
sort: 1
contributors:
- anshumanv
- snitin315
- evenstensberg
- simon04
- tbroadley
Expand Down Expand Up @@ -61,10 +62,10 @@ Note: These are the flags with webpack v4, starting v5 CLI also supports [core f
| `--no-color` | boolean | Disables colors on console |
| `--merge, -m` | boolean | Merge two or more configurations using webpack-merge e.g. `-c ./webpack.config.js -c ./webpack.test.config.js` |
| `--env` | string[] | Environment passed to the configuration when it is a function |
| `--progress` | boolean | Print compilation progress during build |
| `--progress` | boolean, string | Print compilation progress during build |
| `--help` | boolean | Outputs list of supported flags and commands |
| `--output-path, -o` | string | Output location of the file generated by webpack e.g. `./dist` |
| `--target, -t` | string | Sets the build target |
| `--target, -t` | string[] | Sets the build target |
| `--watch, -w` | boolean | Watch for file changes |
| `--hot, -h` | boolean | Enables Hot Module Replacement |
| `--no-hot` | boolean | Disables Hot Module Replacement |
Expand Down Expand Up @@ -94,7 +95,7 @@ __Here's the list of all the core flags supported by webpack v5 with CLI v4 - [l
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 -

```bash
webpack --performance-hints warning`
webpack --performance-hints warning
```

## Usage
Expand Down Expand Up @@ -244,10 +245,11 @@ webpack --env production # sets env.production == true

The `--env` argument accepts multiple values:

| Invocation | Resulting environment |
| ------------------------------ | --------------------------- |
| `webpack --env prod` | `{ prod: true }` |
| `webpack --env prod --env min` | `{ prod: true, min: true }` |
| Invocation | Resulting environment |
| --------------------------------------------- | --------------------------------------- |
| `webpack --env prod` | `{ prod: true }` |
| `webpack --env prod --env min` | `{ prod: true, min: true }` |
| `webpack --env platform=app --env production` | `{ platform: "app", production: true }` |

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

Expand All @@ -270,6 +272,20 @@ webpack --analyze

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

## Progress

To check the progress of any webpack compilation you can use the `--progress` flag.

```bash
webpack --progress
```

To collect profile data for progress steps you can pass `profile` as value to `--progress` flag.

```bash
webpack --progress=profile
```

## Pass CLI arguments to Node.js

To pass arguments directly to Node.js process, you can use the `NODE_OPTIONS` option.
Expand All @@ -285,3 +301,11 @@ Also, you can pass multiple options to Node.js process
```bash
NODE_OPTIONS="--max-old-space-size=4096 -r /path/to/preload/file.js" webpack
```

## Exit codes and their meanings

| Exit Code | Description |
| --------- | -------------------------------------------------- |
| `0` | Success |
| `1` | Errors from webpack |
| `2` | Configuration/options problem or an internal error |
2 changes: 1 addition & 1 deletion src/content/api/loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ loadModule(request: string, callback: function(err, source, sourceMap, module))

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.

`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.
`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.


### `this.resolve`
Expand Down
11 changes: 6 additions & 5 deletions src/content/api/resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ group: Plugins
sort: 13
contributors:
- EugeneHlushko
- chenxsan
---

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

``` js
compiler.resolverFactory.plugin('resolver [type]', resolver => {
resolver.hooks.resolve.tapAsync('MyPlugin', params => {
// ...
compiler.resolverFactory.hooks.resolver.for('[type]').tap('name', resolver => {
// you can tap into resolver.hooks now
resolver.hooks.result.tap('MyPlugin', result => {
return result;
});
});
```

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

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


## Configuration Options
Expand Down
4 changes: 3 additions & 1 deletion src/content/api/stats.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ Each `assets` object represents an `output` file emitted from the compilation. T
'immutable': true, // A flag telling whether the asset can be long term cached (contains a hash)
'size': 1058, // The size in bytes, only becomes available after asset has been emitted
'development': true, // A flag telling whether the asset is only used for development and doesn't count towards user-facing assets
'hotModuleReplacement': true // A flag telling whether the asset ships data for updating an existing application (HMR)
'hotModuleReplacement': true, // A flag telling whether the asset ships data for updating an existing application (HMR)
'sourceFilename': 'originalfile.js', // sourceFilename when asset was created from a source file (potentially transformed)
'javascriptModule': true // true, when asset is javascript and an ESM
}
}
```
Expand Down
21 changes: 11 additions & 10 deletions src/content/blog/2020-10-10-webpack-5-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Webpack 5 release (2020-10-10)
sort: -202010100
contributors:
- sokra
- chenxsan
---

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

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

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.).
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.).

### import.meta

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

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

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.

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

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

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).
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).

## Major Internal Changes

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

### New Watching

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.
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.

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.

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

## Other Minor Changes

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

0 comments on commit ec2f9b0

Please sign in to comment.