@patternslib/dev 4.5.0 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +29 -0
- package/Makefile +45 -3
- package/README.md +114 -20
- package/package.json +1 -1
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.5.1](https://github.com/Patternslib/dev/compare/4.5.0...4.5.1) (2026-11-30)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- **Makefile:** Upgrade targets to remove build:stats and ignore stats files. ([a5f63f8](https://github.com/Patternslib/dev/commit/a5f63f8766b4cebaf82a6b27ce592a73627d22f2))
|
|
8
|
+
|
|
9
|
+
Add upgrade-remove-build-stats, which removes the obsolete build:stats
|
|
10
|
+
script from package.json in favor of make stats.json, and
|
|
11
|
+
upgrade-gitignore-stats, which adds stats.json and stats.html to
|
|
12
|
+
.gitignore. Both commit their change and skip files with uncommitted
|
|
13
|
+
changes, so that unrelated work is never committed.
|
|
14
|
+
|
|
15
|
+
Assisted-by: Claude Opus 5.5
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- **Makefile:** Fall back to webpack-cli config discovery for bundle analysis. ([fd4918d](https://github.com/Patternslib/dev/commit/fd4918de0dbce20be20aa1f8fc4a7b50ec9793f0))
|
|
20
|
+
|
|
21
|
+
Assisted-by: Claude Opus 5.5
|
|
22
|
+
|
|
23
|
+
### Maintenance
|
|
24
|
+
|
|
25
|
+
- **docs:** Update README with recent changes. ([92ad74b](https://github.com/Patternslib/dev/commit/92ad74ba9ad7192b14342b29a9c8d64c1ad8509e))
|
|
26
|
+
- **Makefile:** Add a guard to stats.json to not analyze dev directly. ([c3a451d](https://github.com/Patternslib/dev/commit/c3a451d20f481113b5266134c70468c9d38a8b61))
|
|
27
|
+
|
|
28
|
+
@patternslib/dev has no build script, so it cannot be analyzed directly.
|
|
29
|
+
Print a informational message if the stats.json targed is called from
|
|
30
|
+
within @patternslib/dev.
|
|
31
|
+
|
|
3
32
|
## [4.5.0](https://github.com/Patternslib/dev/compare/4.4.0...4.5.0) (2026-11-30)
|
|
4
33
|
|
|
5
34
|
### Features
|
package/Makefile
CHANGED
|
@@ -25,7 +25,12 @@ BUILDABLE := $(shell node -p "Boolean(require('./package.json').scripts?.build)"
|
|
|
25
25
|
PACKAGE_NAME := $(shell node -p "require('./package.json').name")
|
|
26
26
|
BUNDLE_NAME := $(subst @patternslib/,,$(subst @plone/,,$(PACKAGE_NAME)))
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
# Webpack config for the bundle analysis targets.
|
|
29
|
+
# Patternslib keeps it in webpack/webpack.config.js, most add-ons in the
|
|
30
|
+
# project root. If webpack/webpack.config.js doesn't exist, this is empty and
|
|
31
|
+
# no --config is passed. webpack-cli then uses its own discovery, which finds
|
|
32
|
+
# webpack.config.{js,mjs,cjs,ts,...} in the root or in .webpack/.
|
|
33
|
+
WEBPACK_CONFIG ?= $(wildcard webpack/webpack.config.js)
|
|
29
34
|
# Resolve webpack-cli relative to @patternslib/dev. webpack is a dependency of
|
|
30
35
|
# @patternslib/dev and pnpm doesn't link binaries of indirect dependencies
|
|
31
36
|
# into the consuming project's node_modules/.bin.
|
|
@@ -138,8 +143,15 @@ prerelease-beta:
|
|
|
138
143
|
# broken but up-to-date stats.json behind.
|
|
139
144
|
# With --json, webpack reports compilation errors only within the JSON output.
|
|
140
145
|
# On failure, print them before removing the temporary file.
|
|
146
|
+
# Packages without a build script (like @patternslib/dev itself) have no
|
|
147
|
+
# bundle to analyze. Stop early with a clear message instead of failing
|
|
148
|
+
# with a webpack configuration error.
|
|
141
149
|
stats.json: pnpm-lock.yaml
|
|
142
|
-
|
|
150
|
+
ifneq ($(BUILDABLE),true)
|
|
151
|
+
@echo "$(PACKAGE_NAME) has no build script in package.json - nothing to analyze." >&2
|
|
152
|
+
@exit 1
|
|
153
|
+
endif
|
|
154
|
+
NODE_ENV=production $(WEBPACK_CLI) $(if $(WEBPACK_CONFIG),--config $(WEBPACK_CONFIG)) --json > $@.tmp \
|
|
143
155
|
|| { \
|
|
144
156
|
node -e "try { for (const e of JSON.parse(require('fs').readFileSync('$@.tmp')).errors || []) console.error(e.message || e) } catch {}"; \
|
|
145
157
|
rm -f $@.tmp; \
|
|
@@ -266,9 +278,39 @@ endif
|
|
|
266
278
|
upgrade:\
|
|
267
279
|
.git/hooks/commit-msg\
|
|
268
280
|
upgrade-remove-husky\
|
|
269
|
-
upgrade-eslint
|
|
281
|
+
upgrade-eslint\
|
|
282
|
+
upgrade-remove-build-stats\
|
|
283
|
+
upgrade-gitignore-stats
|
|
270
284
|
@# Upgrade target, depends on other upgrades
|
|
271
285
|
|
|
286
|
+
# The following upgrades only touch files without uncommitted changes, so
|
|
287
|
+
# that they never commit unrelated work. They run again on the next upgrade.
|
|
288
|
+
|
|
289
|
+
# The build:stats script is replaced by the stats.json target.
|
|
290
|
+
upgrade-remove-build-stats:
|
|
291
|
+
@if node -e "process.exit(require('./package.json').scripts?.['build:stats'] ? 0 : 1)"; then \
|
|
292
|
+
if git diff --quiet HEAD -- package.json 2>/dev/null; then \
|
|
293
|
+
npm pkg delete "scripts.build:stats" \
|
|
294
|
+
&& git commit package.json -m"maint: @patternslib/dev upgrade - remove build:stats script in favor of make stats.json."; \
|
|
295
|
+
else \
|
|
296
|
+
echo "Skipping removal of the build:stats script: package.json has uncommitted changes." >&2; \
|
|
297
|
+
fi; \
|
|
298
|
+
fi
|
|
299
|
+
|
|
300
|
+
# Ignore the generated bundle analysis files.
|
|
301
|
+
upgrade-gitignore-stats:
|
|
302
|
+
@if [ -f .gitignore ] && ! { grep -qxF stats.json .gitignore && grep -qxF stats.html .gitignore; }; then \
|
|
303
|
+
if git diff --quiet HEAD -- .gitignore 2>/dev/null; then \
|
|
304
|
+
[ -z "$$(tail -c1 .gitignore)" ] || echo >> .gitignore; \
|
|
305
|
+
for f in stats.json stats.html; do \
|
|
306
|
+
grep -qxF $$f .gitignore || echo $$f >> .gitignore; \
|
|
307
|
+
done \
|
|
308
|
+
&& git commit .gitignore -m"maint: @patternslib/dev upgrade - ignore stats.json and stats.html."; \
|
|
309
|
+
else \
|
|
310
|
+
echo "Skipping the stats.json/stats.html .gitignore update: .gitignore has uncommitted changes." >&2; \
|
|
311
|
+
fi; \
|
|
312
|
+
fi
|
|
313
|
+
|
|
272
314
|
upgrade-remove-husky:
|
|
273
315
|
test -d .husky\
|
|
274
316
|
&& rm -R .husky\
|
package/README.md
CHANGED
|
@@ -2,25 +2,128 @@
|
|
|
2
2
|
|
|
3
3
|
This repository includes base files which are extended in Patternslib, Mockup or other projects.
|
|
4
4
|
|
|
5
|
-
It includes a Makefile which helps in installing and releasing packages.
|
|
5
|
+
It includes a Makefile which helps in installing, testing, building and releasing packages.
|
|
6
|
+
The Makefile uses [pnpm](https://pnpm.io/) as package manager.
|
|
7
|
+
|
|
8
|
+
## Using the Makefile in your project
|
|
9
|
+
|
|
10
|
+
Include the shared Makefile from your project's `Makefile` and repeat the `install` target there.
|
|
11
|
+
On a fresh checkout, `@patternslib/dev` and its Makefile are not installed yet, so your project needs its own `install` target to bootstrap:
|
|
12
|
+
|
|
13
|
+
```makefile
|
|
14
|
+
PNPM ?= npx pnpm
|
|
15
|
+
|
|
16
|
+
-include node_modules/@patternslib/dev/Makefile
|
|
17
|
+
|
|
18
|
+
.PHONY: install
|
|
19
|
+
pnpm-lock.yaml install:
|
|
20
|
+
$(PNPM) install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then run `make install`.
|
|
24
|
+
|
|
25
|
+
## Makefile targets
|
|
26
|
+
|
|
27
|
+
### User targets
|
|
28
|
+
|
|
29
|
+
| Target | Description |
|
|
30
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
31
|
+
| `make install` | Install the dependencies with pnpm and set up the commitlint `commit-msg` git hook. |
|
|
32
|
+
| `make update` | Update pnpm and the project dependencies on a new `dependencies-update` branch. See [Updating dependencies](#updating-dependencies). |
|
|
33
|
+
| `make clean-dist` | Remove the `dist/` directory. |
|
|
34
|
+
| `make clean` | Remove `dist/`, `node_modules/` and the bundle analysis files `stats.json` and `stats.html`. |
|
|
35
|
+
| `make lint`, `make eslint` | Lint the `src/` directory with ESLint. |
|
|
36
|
+
| `make format`, `make prettier` | Format all files with Prettier. |
|
|
37
|
+
| `make check`, `make test` | Run ESLint, then the `test` script from `package.json`. |
|
|
38
|
+
| `make serve`, `make start` | Run the `start` script from `package.json`, e.g. a webpack dev server. |
|
|
39
|
+
| `make watch` | Run the `watch` script from `package.json`. |
|
|
40
|
+
| `make bundle`, `make build` | Clean `dist/` and run the `build` script from `package.json`, if there is one. Runs the `bundle-pre` target first. |
|
|
41
|
+
| `make release-major` | Release a new major version. |
|
|
42
|
+
| `make release-minor` | Release a new minor version. |
|
|
43
|
+
| `make release-patch` | Release a new patch version. |
|
|
44
|
+
| `make prerelease-alpha` | Release a new alpha pre-release. |
|
|
45
|
+
| `make prerelease-beta` | Release a new beta pre-release. |
|
|
46
|
+
|
|
47
|
+
The `test`, `start`, `watch` and `build` scripts are not provided by `@patternslib/dev`.
|
|
48
|
+
Define them in your project's `package.json`.
|
|
49
|
+
|
|
50
|
+
#### Releasing
|
|
51
|
+
|
|
52
|
+
The release targets clean and reinstall the project, run `make check` and then use [release-it](https://github.com/release-it/release-it) to bump the version, generate the changelog, tag, publish to npm and create a GitHub release.
|
|
53
|
+
|
|
54
|
+
- To create GitHub releases, add a `GITHUB_TOKEN` to a `.env` file in your project.
|
|
55
|
+
The Makefile reads `.env` automatically.
|
|
56
|
+
See [release-it GitHub releases](https://github.com/release-it/release-it/blob/master/docs/github-releases.md#automated) and [GitHub tokens](https://github.com/settings/tokens).
|
|
57
|
+
- If your project has a `build` script, the bundle is built after the version bump and attached to the GitHub release as `BUNDLENAME-bundle-VERSION.zip`.
|
|
58
|
+
Include `dist/` in the `files` list of your `package.json`, so that the bundle is also published to npm.
|
|
59
|
+
|
|
60
|
+
To run tasks before the bundle is built, extend the `bundle-pre` target in your Makefile.
|
|
61
|
+
Use double colons, so that the base `bundle-pre` target is also run:
|
|
62
|
+
|
|
63
|
+
```makefile
|
|
64
|
+
bundle-pre::
|
|
65
|
+
-pnpm unlink --recursive
|
|
66
|
+
pnpm install
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Bundle analysis targets
|
|
70
|
+
|
|
71
|
+
These targets build the bundle with webpack and analyze the resulting `stats.json`.
|
|
72
|
+
They need a `build` script in your project's `package.json`.
|
|
73
|
+
|
|
74
|
+
| Target | Description |
|
|
75
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
76
|
+
| `make analyze-bundle-dependencies` | Show why each package was included in the bundle, using [whybundled](https://github.com/d4rkr00t/whybundled). |
|
|
77
|
+
| `make analyze-bundle-treemap` | Show the bundle as treemap, using [webpack-bundle-analyzer](https://github.com/webpack/webpack-bundle-analyzer). |
|
|
78
|
+
| `make analyze-bundle-sunburst` | Render the bundle as sunburst chart into `stats.html` and open it in the browser, using [webpack-visualizer](https://github.com/jonamat/webpack-visualizer). |
|
|
79
|
+
|
|
80
|
+
`stats.json` is rebuilt when `pnpm-lock.yaml` changes.
|
|
81
|
+
To rebuild it after source changes, run `make clean` or delete `stats.json`.
|
|
82
|
+
|
|
83
|
+
### Configuration variables
|
|
84
|
+
|
|
85
|
+
Override these variables in your Makefile or on the command line, e.g. `make analyze-bundle-sunburst OPEN=firefox`.
|
|
86
|
+
|
|
87
|
+
| Variable | Default | Description |
|
|
88
|
+
| ---------------- | ---------------------------------------------- | --------------------------------------------------- |
|
|
89
|
+
| `PNPM` | `npx pnpm` | Command to run pnpm. |
|
|
90
|
+
| `ESLINT` | `npx eslint` | Command to run ESLint. |
|
|
91
|
+
| `PRETTIER` | `npx prettier` | Command to run Prettier. |
|
|
92
|
+
| `WEBPACK_CONFIG` | `webpack/webpack.config.js`, if it exists (\*) | Webpack config used by the bundle analysis targets. |
|
|
93
|
+
| `OPEN` | `xdg-open`, `open` on macOS | Command to open `stats.html` in the browser. |
|
|
94
|
+
|
|
95
|
+
(\*) Otherwise no `--config` is passed and webpack-cli finds the config itself, e.g. `webpack.config.js` in the project root.
|
|
6
96
|
|
|
7
97
|
## Updating dependencies
|
|
8
98
|
|
|
9
99
|
Run `make update` to update the dependencies in this or your dependent project.
|
|
10
100
|
|
|
101
|
+
It creates a `dependencies-update` branch and makes up to three separate commits: one for the pnpm update, one for the updated dependencies in `package.json`, and one for `pnpm-lock.yaml`.
|
|
102
|
+
The dependencies are updated interactively with `pnpm update --latest --interactive`.
|
|
103
|
+
`package.json` must not have uncommitted changes.
|
|
104
|
+
|
|
11
105
|
## Upgrading
|
|
12
106
|
|
|
13
107
|
Run `make upgrade` in your project.
|
|
14
108
|
|
|
15
109
|
Alternatively, if there is a new `@patternslib/dev` version installed, the `postinstall` package.json script will automatically run `make upgrade` in the directory where package installer was invoked, that is your project directory which depends on `@patternslib/dev`.
|
|
16
110
|
|
|
17
|
-
|
|
111
|
+
Each upgrade step creates its own commit. Current upgrades:
|
|
112
|
+
|
|
113
|
+
- Remove the `.husky` directory in favor of git hooks.
|
|
114
|
+
- Create `eslint.config.js` and remove the old `.eslintrc.js`.
|
|
115
|
+
- Remove the `build:stats` script from `package.json`, replaced by `make stats.json`.
|
|
116
|
+
- Add `stats.json` and `stats.html` to `.gitignore`.
|
|
117
|
+
|
|
118
|
+
The last two steps skip files with uncommitted changes and run again on the next upgrade.
|
|
18
119
|
|
|
19
|
-
|
|
20
|
-
If you choose to migrate, update the consuming project's configuration and workflows explicitly.
|
|
21
|
-
The shared Makefile uses pnpm for installation and for running build, test, and start scripts.
|
|
120
|
+
## Migrating a consuming package from Yarn to pnpm
|
|
22
121
|
|
|
23
|
-
|
|
122
|
+
`@patternslib/dev` switched from Yarn to pnpm in version 4.3.0.
|
|
123
|
+
The shared Makefile uses pnpm for installation and for running the build, test and start scripts.
|
|
124
|
+
Projects which still use Yarn should migrate:
|
|
125
|
+
|
|
126
|
+
1. Pin the pnpm version you intend to use in your project's `package.json`:
|
|
24
127
|
|
|
25
128
|
```json
|
|
26
129
|
"packageManager": "pnpm@12.3.4",
|
|
@@ -45,23 +148,14 @@ The shared Makefile uses pnpm for installation and for running build, test, and
|
|
|
45
148
|
|
|
46
149
|
For more information, see the [pnpm configuration reference](https://pnpm.io/settings).
|
|
47
150
|
|
|
48
|
-
3. Change the `yarn` references in
|
|
49
|
-
|
|
50
|
-
```makefile
|
|
51
|
-
PNPM ?= npx pnpm
|
|
52
|
-
|
|
53
|
-
-include node_modules/@patternslib/dev/Makefile
|
|
54
|
-
|
|
55
|
-
.PHONY: install
|
|
56
|
-
pnpm-lock.yaml install:
|
|
57
|
-
$(PNPM) install
|
|
58
|
-
```
|
|
151
|
+
3. Change the `yarn` references in your Makefile to use `pnpm`, as shown in [Using the Makefile in your project](#using-the-makefile-in-your-project).
|
|
59
152
|
|
|
60
|
-
If you use `yarn link` or `yarn unlink` in your Makefile, update it to fit the new [pnpm syntax](https://pnpm.io/cli/link).
|
|
153
|
+
If you use `yarn link` or `yarn unlink` in your Makefile, update it to fit the new [pnpm syntax](https://pnpm.io/cli/link).
|
|
61
154
|
|
|
62
|
-
4. You might need to include pnpm
|
|
155
|
+
4. You might need to include pnpm in the `transformIgnorePatterns` field of your Jest configuration to make the tests pass.
|
|
156
|
+
See this project's `jest.config.js` for an example.
|
|
63
157
|
|
|
64
|
-
5. Update the CI configuration to use
|
|
158
|
+
5. Update the CI configuration to use pnpm and its cache - see this project's `.github/workflows/test.yml`.
|
|
65
159
|
|
|
66
160
|
6. Run `make install`, add `pnpm-lock.yaml` to the git repository and remove `yarn.lock`.
|
|
67
161
|
|