Skip to content

Commit 393f249

Browse files
refactor: next
BREAKING CHANGE: yes
1 parent a80213f commit 393f249

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1243
-17429
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
matrix:
5757
os: [ubuntu-latest, windows-latest, macos-latest]
5858
node-version: [10.x, 12.x, 14.x]
59-
webpack-version: [4, latest]
59+
webpack-version: [latest]
6060

6161
runs-on: ${{ matrix.os }}
6262

README.md

Lines changed: 11 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ module.exports = {
4141

4242
And run `webpack` via your preferred method.
4343

44+
## Note about source maps
45+
46+
**Works only with `source-map`, `inline-source-map`, `hidden-source-map` and `nosources-source-map` values for the [`devtool`](https://webpack.js.org/configuration/devtool/) option.**
47+
48+
Why?
49+
50+
- `eval` wraps modules in `eval("string")` and the minimizer does not handle strings.
51+
- `cheap` has not column information and minimizer generate only a single line, which leave only a single mapping.
52+
53+
Using supported `devtool` values enable source map generation.
54+
4455
## Options
4556

4657
### `test`
@@ -109,98 +120,6 @@ module.exports = {
109120
};
110121
```
111122

112-
### `cache`
113-
114-
> ⚠ Ignored in webpack 5! Please use https://webpack.js.org/configuration/other-options/#cache.
115-
116-
Type: `Boolean|String`
117-
Default: `true`
118-
119-
Enable file caching.
120-
Default path to cache directory: `node_modules/.cache/terser-webpack-plugin`.
121-
122-
> ℹ️ If you use your own `minify` function please read the `minify` section for cache invalidation correctly.
123-
124-
#### `Boolean`
125-
126-
Enable/disable file caching.
127-
128-
**webpack.config.js**
129-
130-
```js
131-
module.exports = {
132-
optimization: {
133-
minimize: true,
134-
minimizer: [
135-
new TerserPlugin({
136-
cache: true,
137-
}),
138-
],
139-
},
140-
};
141-
```
142-
143-
#### `String`
144-
145-
Enable file caching and set path to cache directory.
146-
147-
**webpack.config.js**
148-
149-
```js
150-
module.exports = {
151-
optimization: {
152-
minimize: true,
153-
minimizer: [
154-
new TerserPlugin({
155-
cache: 'path/to/cache',
156-
}),
157-
],
158-
},
159-
};
160-
```
161-
162-
### `cacheKeys`
163-
164-
> ⚠ Ignored in webpack 5! Please use https://webpack.js.org/configuration/other-options/#cache.
165-
166-
Type: `Function<(defaultCacheKeys, file) -> Object>`
167-
Default: `defaultCacheKeys => defaultCacheKeys`
168-
169-
Allows you to override default cache keys.
170-
171-
Default cache keys:
172-
173-
```js
174-
({
175-
terser: require('terser/package.json').version, // terser version
176-
'terser-webpack-plugin': require('../package.json').version, // plugin version
177-
'terser-webpack-plugin-options': this.options, // plugin options
178-
nodeVersion: process.version, // Node.js version
179-
name: file, // asset path
180-
contentHash: crypto.createHash('md4').update(input).digest('hex'), // source file hash
181-
});
182-
```
183-
184-
**webpack.config.js**
185-
186-
```js
187-
module.exports = {
188-
optimization: {
189-
minimize: true,
190-
minimizer: [
191-
new TerserPlugin({
192-
cache: true,
193-
cacheKeys: (defaultCacheKeys, file) => {
194-
defaultCacheKeys.myCacheKey = 'myCacheKeyValue';
195-
196-
return defaultCacheKeys;
197-
},
198-
}),
199-
],
200-
},
201-
};
202-
```
203-
204123
### `parallel`
205124

206125
Type: `Boolean|Number`
@@ -251,40 +170,6 @@ module.exports = {
251170
};
252171
```
253172

254-
### `sourceMap`
255-
256-
Type: `Boolean`
257-
Default: `false` (see below for details around `devtool` value and `SourceMapDevToolPlugin` plugin)
258-
259-
**Works only with `source-map`, `inline-source-map`, `hidden-source-map` and `nosources-source-map` values for the [`devtool`](https://webpack.js.org/configuration/devtool/) option.**
260-
261-
Why?
262-
263-
- `eval` wraps modules in `eval("string")` and the minimizer does not handle strings.
264-
- `cheap` has not column information and minimizer generate only a single line, which leave only a single mapping.
265-
266-
The plugin respect the [`devtool`](https://webpack.js.org/configuration/devtool/) and using the `SourceMapDevToolPlugin` plugin.
267-
Using supported `devtool` values enable source map generation.
268-
Using `SourceMapDevToolPlugin` with enabled the `columns` option enables source map generation.
269-
270-
Use source maps to map error message locations to modules (this slows down the compilation).
271-
If you use your own `minify` function please read the `minify` section for handling source maps correctly.
272-
273-
**webpack.config.js**
274-
275-
```js
276-
module.exports = {
277-
optimization: {
278-
minimize: true,
279-
minimizer: [
280-
new TerserPlugin({
281-
sourceMap: true,
282-
}),
283-
],
284-
},
285-
};
286-
```
287-
288173
### `minify`
289174

290175
Type: `Function`

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
module.exports = {
22
testEnvironment: 'node',
3-
snapshotResolver: './test/helpers/snapshotResolver.js',
43
};

lint-staged.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
'*.js': ['prettier --write', 'eslint --fix'],
2+
'*.js': ['eslint --fix', 'prettier --write'],
33
'*.{json,md,yml,css,ts}': ['prettier --write'],
44
};

0 commit comments

Comments
 (0)