Skip to content

Commit 450a210

Browse files
authored
Merge pull request #244 from humanmade/release-1.0.0
Release v1.0.0
2 parents 625a796 + 63a39d6 commit 450a210

9 files changed

Lines changed: 260 additions & 44 deletions

File tree

docs/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ source "https://rubygems.org"
33
gem "jekyll", "~> 4.3.2"
44
gem "webrick", "~> 1.8"
55
gem "just-the-hm-docs", github: "humanmade/just-the-hm-docs"
6+
gem "jekyll-include-cache"

docs/_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ url: "https://humanmade.github.io" # the base hostname & protocol for your site,
2222
# Theme settings
2323
theme: just-the-hm-docs
2424

25+
plugins:
26+
- jekyll-include-cache
27+
2528
# Aux links for the upper right navigation
2629
aux_links:
2730
Webpack-Helpers on GitHub:

docs/changelog.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,40 @@ nav_order: 10
66

77
# Changelog
88

9-
## v1.0.0-alpha
9+
## v1.0.0
10+
11+
This is a major release that migrates the package from Webpack 4 to Webpack 5, removes several legacy loaders and plugins, and raises the minimum Node.js version to 22. See the [migration guide](https://humanmade.github.io/webpack-helpers/guides/migrating-from-0x) for step-by-step upgrade instructions.
1012

1113
### Added
1214

13-
- Full Webpack 5 support with modern optimizations and performance improvements
14-
- ESLint 9+ support with flat configuration format (`eslint.config.js`)
15-
- Modern `eslint-webpack-plugin` replacing deprecated `eslint-loader`
16-
- Enhanced TypeScript support for `.ts` and `.tsx` files
17-
- Updated peer dependencies to latest stable versions
18-
- Improved build performance with Webpack 5's enhanced tree shaking
19-
- Module federation capabilities support
15+
- **`loaders.asset()`**: New loader factory using Webpack 5's native `asset` module type. Files under 10 KB are inlined as data URLs; larger files are emitted as separate resources. Replaces the removed `loaders.url()`.
16+
- **`loaders.assetResource()`**: New loader factory using Webpack 5's `asset/resource` type. Always emits the file as a separate resource. Replaces the removed `loaders.file()`.
17+
- **`loaders.assetInline()`**: New loader factory using Webpack 5's `asset/inline` type. Always inlines the file as a data URL.
18+
- **`plugins.eslint()`**: New plugin factory wrapping [`eslint-webpack-plugin`](https://github.com/webpack-contrib/eslint-webpack-plugin). Replaces the removed `loaders.eslint()`. Requires ESLint 9+ with flat configuration format.
19+
- **`plugins.cssMinimizer()`**: New plugin factory wrapping [`css-minimizer-webpack-plugin`](https://github.com/webpack-contrib/css-minimizer-webpack-plugin). Replaces the removed `plugins.optimizeCssAssets()`. Included in `presets.production()`.
2020

2121
### Changed
2222

23-
- **BREAKING**: Upgraded from Webpack 4 to Webpack 5
24-
- **BREAKING**: Updated ESLint support to use ESLint 9+ flat configuration format
25-
- **BREAKING**: Replaced deprecated `eslint-loader` with `eslint-webpack-plugin`
26-
- **BREAKING**: Updated minimum Node.js requirement to align with Webpack 5
27-
- Updated all bundled dependencies to latest stable versions
28-
- Improved error handling and debugging capabilities
29-
- Enhanced development server performance
23+
- **BREAKING**: Minimum Node.js version is now **22.0.0**.
24+
- **BREAKING**: Webpack 5 is now required. Update your project's peer dependencies to `webpack@^5`, `webpack-cli@^5`, and `webpack-dev-server@^5`.
25+
- **BREAKING**: `loaders.url()` has been removed. Use `loaders.asset()` or `loaders.assetInline()` instead.
26+
- **BREAKING**: `loaders.file()` has been removed. Use `loaders.assetResource()` instead.
27+
- **BREAKING**: `loaders.eslint()` has been removed. Add `plugins.eslint()` to your `plugins` array instead.
28+
- **BREAKING**: `plugins.optimizeCssAssets()` has been removed. Use `plugins.cssMinimizer()` instead.
29+
- **BREAKING**: `plugins.constructors.OptimizeCssAssetsPlugin` has been removed. Use `plugins.constructors.CssMinimizerPlugin` instead.
30+
- **BREAKING**: ESLint 9+ is now required. The flat configuration format (`eslint.config.js` / `eslint.config.mjs`) is required; legacy `.eslintrc.*` files are not supported.
31+
- **BREAKING**: If you have custom `optimization` configuration that sets `noEmitOnErrors: true`, rename the option to `emitOnErrors: false` (the Webpack 5 equivalent).
32+
- `eslint-webpack-plugin` moved from `devDependencies` to `dependencies`, ensuring it is available to consuming projects at load time.
33+
- `eslint@^9.0.0` declared as an optional peer dependency, surfacing the ESLint version requirement and avoiding `ajv` version conflicts with other plugins.
34+
- All bundled loader and plugin dependencies updated to current major versions.
3035

3136
### Removed
3237

33-
- Support for legacy `.eslintrc.*` configuration files (use `eslint.config.js` instead)
34-
- Webpack 4 compatibility and related legacy code
35-
- `eslint-loader` dependency (replaced with `eslint-webpack-plugin`)
36-
- Outdated peer dependency constraints
37-
38-
### Migration Guide
39-
40-
- Update your `package.json` to use `webpack@5`, `webpack-cli@5`, and `webpack-dev-server@5`
41-
- If using ESLint, migrate from `.eslintrc.*` files to `eslint.config.js` using the flat configuration format
42-
- Review and update any custom webpack configurations to ensure Webpack 5 compatibility
43-
- Update Node.js to a supported version if needed
38+
- `loaders.url()` — replaced by `loaders.asset()` / `loaders.assetInline()`
39+
- `loaders.file()` — replaced by `loaders.assetResource()`
40+
- `loaders.eslint()` — replaced by `plugins.eslint()`
41+
- `plugins.optimizeCssAssets()` — replaced by `plugins.cssMinimizer()`
42+
- `plugins.constructors.OptimizeCssAssetsPlugin` — replaced by `plugins.constructors.CssMinimizerPlugin`
4443

4544
## v0.12.0
4645

docs/guides/getting-started.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ npm install --save-dev @humanmade/webpack-helpers
1616

1717
While this package depends in turn on a number of loaders and plugins, it deliberately does _not_ include `webpack` itself. To install this library along with all its relevant peer dependencies, therefore, you may run the following command:
1818

19-
** *Check notice before proceeding:**
2019
```bash
21-
npm install --save-dev @humanmade/webpack-helpers webpack@5 webpack-cli@6 webpack-dev-server@5 sass
20+
npm install --save-dev @humanmade/webpack-helpers webpack@5 webpack-cli@5 webpack-dev-server@5 sass
2221
```
2322

24-
**Webpack 5 Support:** This package now fully supports Webpack 5 with all the latest features and optimizations. We recommend using Webpack 5 for all new projects as it provides better performance, improved tree shaking, and enhanced module federation capabilities.
23+
**Node.js 22+ is required.** This project includes an `.nvmrc` file; if you use nvm, run `nvm use` to switch to the correct version.
2524

2625
## Configuring Webpack
2726

docs/guides/migrating-from-0x.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
---
2+
title: Migrating from 0.x
3+
parent: Guides
4+
nav_order: 1
5+
---
6+
7+
# Migrating from 0.x to 1.0
8+
9+
Version 1.0 is a major release that migrates the package to Webpack 5, drops several legacy loaders and plugins, and raises the minimum Node.js version. This guide covers every breaking change with before/after examples.
10+
11+
## 1. Upgrade Node.js to 22+
12+
13+
Node.js 22 is now required. Check your current version with `node --version`. If you use nvm:
14+
15+
```bash
16+
nvm install 22
17+
nvm use 22
18+
```
19+
20+
An `.nvmrc` file is included in the project; `nvm use` with no arguments will pick up the correct version automatically.
21+
22+
## 2. Upgrade peer dependencies
23+
24+
Update `webpack`, `webpack-cli`, and `webpack-dev-server` in your project:
25+
26+
```bash
27+
npm install --save-dev webpack@5 webpack-cli@5 webpack-dev-server@5
28+
```
29+
30+
Webpack 5 contains breaking changes of its own. If you maintain any custom webpack configuration beyond what the presets provide, consult the [Webpack 5 migration guide](https://webpack.js.org/migrate/5/) alongside this one.
31+
32+
## 3. Replace `loaders.url()` and `loaders.file()`
33+
34+
`loaders.url()` and `loaders.file()` have been removed. Webpack 5 handles binary assets natively via [asset modules](https://webpack.js.org/guides/asset-modules/), so these third-party loaders are no longer needed.
35+
36+
The presets already use the new loaders by default. If you referenced the old loaders directly in custom configuration, replace them as follows:
37+
38+
**`loaders.url()``loaders.asset()`**
39+
40+
`url-loader` inlined small files as data URLs and emitted larger files to disk. `loaders.asset()` provides the same behaviour using Webpack's native asset module:
41+
42+
```js
43+
// Before
44+
module.exports = {
45+
module: {
46+
rules: [
47+
loaders.url( { options: { limit: 10000 } } ),
48+
],
49+
},
50+
};
51+
52+
// After
53+
module.exports = {
54+
module: {
55+
rules: [
56+
loaders.asset(), // 10 KB threshold by default
57+
],
58+
},
59+
};
60+
```
61+
62+
To adjust the inline size threshold, mutate the defaults or use `filterLoaders`:
63+
64+
```js
65+
// Mutate defaults directly
66+
loaders.asset.defaults.parser.dataUrlCondition.maxSize = 5000;
67+
68+
// Or via filterLoaders in a preset
69+
presets.production( options, {
70+
filterLoaders: ( loader, loaderType ) => {
71+
if ( loaderType === 'asset' ) {
72+
loader.parser.dataUrlCondition.maxSize = 5000;
73+
}
74+
return loader;
75+
},
76+
} );
77+
```
78+
79+
**`loaders.file()``loaders.assetResource()`**
80+
81+
`file-loader` always emitted files to disk. `loaders.assetResource()` is the equivalent:
82+
83+
```js
84+
// Before
85+
loaders.file()
86+
87+
// After
88+
loaders.assetResource()
89+
```
90+
91+
**`loaders.assetInline()`** is also available if you want to always inline a file as a data URL, regardless of size.
92+
93+
Note that asset modules do not support `options.publicPath` on the rule itself. Set [`output.publicPath`](https://webpack.js.org/configuration/output/#outputpublicpath) at the top level of your webpack config instead.
94+
95+
## 4. Replace `loaders.eslint()` with `plugins.eslint()`
96+
97+
ESLint linting has moved from a loader rule to a webpack plugin. Remove `loaders.eslint()` from your `module.rules` array and add `plugins.eslint()` to your `plugins` array.
98+
99+
```js
100+
// Before
101+
const { loaders, presets } = require( '@humanmade/webpack-helpers' );
102+
103+
module.exports = {
104+
module: {
105+
rules: [
106+
loaders.eslint(),
107+
loaders.js(),
108+
// ...
109+
],
110+
},
111+
};
112+
113+
// After
114+
const { plugins, presets } = require( '@humanmade/webpack-helpers' );
115+
116+
module.exports = presets.production( {
117+
plugins: [
118+
plugins.eslint(),
119+
],
120+
// ...
121+
} );
122+
```
123+
124+
ESLint is not added automatically by the presets — you must add `plugins.eslint()` explicitly if you want linting as part of your build.
125+
126+
## 5. Replace `plugins.optimizeCssAssets()` with `plugins.cssMinimizer()`
127+
128+
`plugins.optimizeCssAssets()` has been removed along with the `optimize-css-assets-webpack-plugin` dependency. The replacement is `plugins.cssMinimizer()`, which wraps `css-minimizer-webpack-plugin` and is already included in `presets.production()`.
129+
130+
If you referenced `plugins.optimizeCssAssets()` directly in a custom `optimization.minimizer` array:
131+
132+
```js
133+
// Before
134+
const config = presets.production( { entry, output } );
135+
module.exports = {
136+
...config,
137+
optimization: {
138+
...config.optimization,
139+
minimizer: [
140+
plugins.terser(),
141+
plugins.optimizeCssAssets(),
142+
],
143+
},
144+
};
145+
146+
// After
147+
module.exports = {
148+
...config,
149+
optimization: {
150+
...config.optimization,
151+
minimizer: [
152+
plugins.terser(),
153+
plugins.cssMinimizer(),
154+
],
155+
},
156+
};
157+
```
158+
159+
If you used `plugins.constructors.OptimizeCssAssetsPlugin` directly, switch to `plugins.constructors.CssMinimizerPlugin`.
160+
161+
## 6. Migrate your ESLint configuration to flat config format
162+
163+
ESLint 9+ requires the new flat configuration format. The legacy `.eslintrc`, `.eslintrc.js`, `.eslintrc.json`, and `.eslintrc.yml` files are not supported.
164+
165+
Create an `eslint.config.js` (or `eslint.config.mjs`) file in your project root. A minimal example:
166+
167+
```js
168+
// eslint.config.js
169+
import js from '@eslint/js';
170+
171+
export default [
172+
js.configs.recommended,
173+
{
174+
files: [ '**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx' ],
175+
languageOptions: {
176+
ecmaVersion: 2024,
177+
sourceType: 'module',
178+
},
179+
rules: {
180+
// your project rules
181+
},
182+
},
183+
];
184+
```
185+
186+
Refer to the [ESLint flat config migration guide](https://eslint.org/docs/latest/use/configure/migration-guide) for a complete reference, including how to translate common `.eslintrc` options.
187+
188+
## 7. Update custom `optimization` config (if applicable)
189+
190+
Webpack 5 renamed the `noEmitOnErrors` optimization option to `emitOnErrors`, with the boolean sense inverted. If you have a custom `optimization` block:
191+
192+
```js
193+
// Before (Webpack 4)
194+
module.exports = {
195+
optimization: {
196+
noEmitOnErrors: true,
197+
},
198+
};
199+
200+
// After (Webpack 5)
201+
module.exports = {
202+
optimization: {
203+
emitOnErrors: false,
204+
},
205+
};
206+
```
207+
208+
If you use the presets without customising `optimization`, no change is needed.

docs/modules/loaders.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ nav_order: 3
1010

1111
This module provides functions that generate configurations for commonly-needed Webpack loaders. Use them within the `.module.rules` array, or use `presets.development()`/`presets.production()` to opt-in to some opinionated defaults.
1212

13-
- `loaders.eslint()`: Return a configured Webpack module loader rule for `eslint-loader`.
14-
- `loaders.js()`: Return a configured Webpack module loader rule for `js-loader`.
15-
- `loaders.ts()`: Return a configured Webpack module loader rule for `ts-loader`.
16-
- `loaders.url()`: Return a configured Webpack module loader rule for `url-loader`.
17-
- `loaders.style()`: Return a configured Webpack module loader rule for `style-loader`.
18-
- `loaders.css()`: Return a configured Webpack module loader rule for `css-loader`.
19-
- `loaders.postcss()`: Return a configured Webpack module loader rule for `postcss-loader`.
20-
- `loaders.sass()`: Return a configured Webpack module loader rule for `sass-loader`.
21-
- `loaders.file()`: Return a configured Webpack module loader rule for `file-loader`.
13+
- `loaders.js()`: Return a configured Webpack module rule for `babel-loader`.
14+
- `loaders.ts()`: Return a configured Webpack module rule for `ts-loader`. Only injected by presets if the `typescript` package is installed.
15+
- `loaders.asset()`: Return a Webpack 5 [asset module](https://webpack.js.org/guides/asset-modules/) rule using type `asset`. Files under 10 KB are inlined as data URLs; larger files are emitted as separate resources. Replaces the removed `url-loader`.
16+
- `loaders.assetResource()`: Return a Webpack 5 asset module rule using type `asset/resource`. Always emits the file as a separate resource. Replaces the removed `file-loader`.
17+
- `loaders.assetInline()`: Return a Webpack 5 asset module rule using type `asset/inline`. Always inlines the file as a data URL.
18+
- `loaders.style()`: Return a configured Webpack module rule for `style-loader`.
19+
- `loaders.css()`: Return a configured Webpack module rule for `css-loader`.
20+
- `loaders.postcss()`: Return a configured Webpack module rule for `postcss-loader`.
21+
- `loaders.sass()`: Return a configured Webpack module rule for `sass-loader`.
2222

2323
## Customizing Loaders
2424

docs/modules/plugins.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ This module provides methods which create new instances of commonly-needed Webpa
1515
  | `plugins.bundleAnalyzer()` | Create and return a new [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer) instance. When included this plugin is disabled by default unless the `--analyze` flag is passed on the command line.
1616
  | `plugins.clean()` | Create and return a new [`clean-webpack-plugin`](https://github.com/johnagan/clean-webpack-plugin) instance.
1717
  | `plugins.copy()` | Create and return a new [`copy-webpack-plugin`](https://github.com/webpack-contrib/copy-webpack-plugin) instance.
18+
**P** | `plugins.cssMinimizer()` | Create and return a new [`css-minimizer-webpack-plugin`](https://github.com/webpack-contrib/css-minimizer-webpack-plugin) instance. Replaces the removed `plugins.optimizeCssAssets()`.
1819
  | `plugins.errorBell()` | Create and return a new [`bell-on-bundle-error-plugin`](https://www.npmjs.com/package/bell-on-bundler-error-plugin) instance.
20+
  | `plugins.eslint()` | Create and return a new [`eslint-webpack-plugin`](https://github.com/webpack-contrib/eslint-webpack-plugin) instance. Requires ESLint 9+ with flat configuration format (`eslint.config.js`). Replaces the removed `loaders.eslint()`.
1921
  | `plugins.fixStyleOnlyEntries()` | Create and return a [`webpack-fix-style-only-entries`](https://github.com/fqborges/webpack-fix-style-only-entries) instance to remove empty JS bundles for style-only entrypoints.
2022
**D** | `plugins.hotModuleReplacement()` | Create and return a new [`webpack.HotModuleReplacementPlugin`](https://webpack.js.org/plugins/hot-module-replacement-plugin/) instance.
21-
  | `plugins.manifest()` | : Create and return a new [`webpack-manifest-plugin`](https://github.com/danethurber/webpack-manifest-plugin) instance, preconfigured to write the manifest file while running from a dev server.
23+
  | `plugins.manifest()` | Create and return a new [`webpack-manifest-plugin`](https://github.com/danethurber/webpack-manifest-plugin) instance, preconfigured to write the manifest file while running from a dev server.
2224
**P** | `plugins.miniCssExtract()` | Create and return a new [`mini-css-extract-plugin`](https://github.com/webpack-contrib/mini-css-extract-plugin) instance.
2325
**P** | `plugins.terser()` | Create and return a new [`terser-webpack-plugin`](https://github.com/webpack-contrib/terser-webpack-plugin) instance, preconfigured with defaults based on `create-react-app`.
2426

docs/modules/presets.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,17 @@ Note that array values are _merged_, not overwritten. This allows you to easily
116116
Adjusting loaders within a generated configuration tree is difficult because loader arrays are not keyed and module rules may be nested. Instead, each `preset` generator accepts a second argument in which you can pass a callback function that will be run on the output of each computed loader definition.
117117

118118
```js
119-
// Alter the publicPath value of the files-loader and url-loader.
120-
const config = production.preset(
119+
// Restrict the JS loader to a specific source directory, and lower the
120+
// size threshold below which asset files are inlined as data URLs.
121+
const config = presets.production(
121122
{ /* ...configuration options described above ... */ },
122123
{
123124
filterLoaders: ( loader, loaderType ) => {
124-
if ( loaderType === 'file' || loaderType === 'url' ) {
125-
loader.options.publicPath = '../../';
125+
if ( loaderType === 'js' ) {
126+
loader.include = helpers.filePath( 'themes/my-theme/src' );
127+
}
128+
if ( loaderType === 'asset' ) {
129+
loader.parser.dataUrlCondition.maxSize = 5000;
126130
}
127131
return loader;
128132
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@humanmade/webpack-helpers",
33
"public": true,
4-
"version": "1.0.0-alpha",
4+
"version": "1.0.0",
55
"description": "Reusable Webpack configuration components & related helper utilities.",
66
"main": "index.js",
77
"author": "Human Made",

0 commit comments

Comments
 (0)