@patternslib/dev 4.3.0 → 4.5.0

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/.node-version ADDED
@@ -0,0 +1 @@
1
+ 24
package/AGENTS.md ADDED
@@ -0,0 +1,75 @@
1
+ # @patternslib/dev
2
+
3
+ ## About this project
4
+
5
+ This is the common development configuration files for Patternslib and related
6
+ projects like Pattern addons or Mockup.
7
+
8
+ ## Architecture Decision Records
9
+
10
+ Record significant decisions made during agentic sessions as Architecture
11
+ Decision Records (ADRs) in `./docs/adr/`.
12
+
13
+ - Write an ADR when a session makes a non-trivial design, architecture or
14
+ styling decision, or a change whose reasoning is not obvious from the
15
+ code. Q&A, reviews and trivial fixes need none. If unsure, ask.
16
+ - Start with a draft ADR, so that it can be referenced from source commits.
17
+ - Multiple commits can reference one ADR.
18
+ - One ADR per decision, not per session. Write it when the decision is
19
+ implemented, before committing.
20
+ - File name: `NNNN-short-kebab-title.md`, numbered consecutively.
21
+ - Sections: title, `Status: <Proposed|Accepted|Superseded by NNNN> (YYYY-MM-DD)`,
22
+ Context, Decision, Consequences. See `0001-*.md` as an example.
23
+ - Unpushed ADRs may be rewritten freely. Once pushed, an accepted ADR is
24
+ only changed for typos and clarifications; to revise the decision, write
25
+ a new ADR and mark the old one `Superseded by NNNN`.
26
+ - If a source commit implements a decision documented in an ADR, reference that ADR in the commit message as:
27
+
28
+ ```
29
+ ORIGINAL COMMIT MESSAGE
30
+
31
+ Ref: ADR NNNN
32
+ ```
33
+
34
+ ## Commit messages
35
+
36
+ - We use a commitlint pre-commit hook. The message format is:
37
+
38
+ ```
39
+ <TYPE>(<COMPONENT>): <TITLE>
40
+
41
+ <MESSAGE>
42
+ ```
43
+
44
+ - `<TYPE>`: One of: "breaking" (for breaking changes), "feat" (for features), fix (for bug fixes), tech (technical changes), maint (for maintenance work).
45
+ - `<COMPONENT>`: `pat-<PATTERNNAME>` for Pattern fixes, `core <MODULE_NAME>` for fixes in core.
46
+
47
+ - If a source commit implements a decision documented in an ADR, reference that ADR in the commit message as:
48
+
49
+ ```
50
+ ORIGINAL COMMIT MESSAGE
51
+
52
+ Ref: ADR NNNN
53
+ ```
54
+
55
+ - If a commit was done with significant help from someone else, append this to the commit message:
56
+
57
+ ```
58
+ ORIGINAL COMMIT MESSAGE
59
+
60
+ Co-Authored-By: NAME <EMAIL>
61
+ ```
62
+
63
+ - If a commit was done with significant help from an AI, append this to the commit message:
64
+
65
+ ```
66
+ ORIGINAL COMMIT MESSAGE
67
+
68
+ Assisted-by: NAME
69
+ ```
70
+
71
+ Don't use `Co-Authored-By` for AI contributions, as for Plone and other projects we need a contributor agreement for commits and an AI cannot sign it.
72
+
73
+ `<NAME>` should be the Model name and version, e.g. `Claude Opus 5.5`. Don't include the email, it's not useful.
74
+
75
+ - Use these rules in order as they are defined here - first ADR, then scrum, then co-authored, then assisted references.
package/CHANGES.md CHANGED
@@ -1,5 +1,93 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.5.0](https://github.com/Patternslib/dev/compare/4.4.0...4.5.0) (2026-11-30)
4
+
5
+ ### Features
6
+
7
+ - **Makefile:** Add analyze-bundle-sunburst. ([920a460](https://github.com/Patternslib/dev/commit/920a460895fa7192a7b54d6f74025caca83cfa9b))
8
+
9
+ The dependency tree is displayed in a sunburst map, which gives a good
10
+ overview of which packages add the biggest weight.
11
+
12
+ - **Makefile:** Add new target name aliases. ([151324b](https://github.com/Patternslib/dev/commit/151324bca0ff1aa6a480214c6c51bfd49ed89f9d))
13
+
14
+ - start (alias for: serve)
15
+ - build (alias for: bundle)
16
+ - test (alias for: check)
17
+ - lint (alias for: eslint)
18
+ - format (alias for: prettier)
19
+
20
+ - **Makefile:** Add watch target - needs to be implemented in package.json. ([366cf3a](https://github.com/Patternslib/dev/commit/366cf3af46cb15e6fbde1ce3cfca7341505f3d2a))
21
+ - **Makefile:** New targets for bundle analyzing. ([5c57519](https://github.com/Patternslib/dev/commit/5c57519ae6ec09374aab2326c486d69afe821f9c))
22
+
23
+ This package's dependencies on whybundled and webpack-bundle-analyzer
24
+ have been removed. Instead, there are two new makefile targets:
25
+
26
+ - analyze-bundle-dependencies (whybundled)
27
+ - analyze-bundle-treemap (webpack-bundle-analyzer)
28
+
29
+ ### Bug Fixes
30
+
31
+ - **Babel:** Use imports relative to @patternslib/dev. ([e591850](https://github.com/Patternslib/dev/commit/e591850a7205934c5a90a367d6292b8044ec98b3))
32
+
33
+ Depending packages might not have all dependencies installed.
34
+
35
+ - **Makefile:** Fix missing version in release bundle name when not logged in to npm. ([b90dc10](https://github.com/Patternslib/dev/commit/b90dc102adde0e3c35dbe97f781e34c4aae4a0de))
36
+
37
+ `release-it --release-version` runs in CI mode, where the npm plugin
38
+ cannot do the interactive login. When not logged in to npm it failed
39
+ silently, leaving PACKAGE_VERSION empty. The GitHub release asset was
40
+ then looked up as `<name>-bundle-.zip` and not uploaded.
41
+
42
+ Skip the npm checks when determining the version - they are still run
43
+ in the actual release run. Also abort if the version cannot be
44
+ determined.
45
+
46
+ Assisted-by: Claude Opus 5.5
47
+
48
+ - **Makefile:** Open sunburst stats.html directly in browser. ([fe885bf](https://github.com/Patternslib/dev/commit/fe885bfdf85b18e845f45ef67ba4e20f509dd540))
49
+ - **webpack:** Fix test for loaders configured with resolved paths. ([5cf5071](https://github.com/Patternslib/dev/commit/5cf5071bfe5953004c1acd919149c196db62b1d1))
50
+
51
+ The webpack and Babel configs now name their loaders and presets by the
52
+ resolved path from @patternslib/dev instead of a bare package name.
53
+ Webpack and Babel look up bare names from the consuming project, so a
54
+ build only worked if the project happened to have them, e.g. through
55
+ shamefully-hoist.
56
+ Resolved paths also work when @patternslib/dev is linked or not hoisted.
57
+
58
+ The test compared the loader by name, so it no longer removed the
59
+ style-loader. It now compares against the resolved path, and the
60
+ resolveLoader workaround is no longer needed.
61
+
62
+ Assisted-by: Claude Opus 5.5
63
+
64
+ - **webpack:** Use imports relative to @patternslib/dev. ([b8032f1](https://github.com/Patternslib/dev/commit/b8032f1f108c30be1bdaadb5fba75ae2e3ab727f))
65
+
66
+ Depending packages might not have all dependencies installed.
67
+
68
+ ### Maintenance
69
+
70
+ - **Makefile:** Restructure and move all user-targeted targets on top. ([51cd1c2](https://github.com/Patternslib/dev/commit/51cd1c223b2020aee720d3fcfaed93f611977689))
71
+ - Update dependencies. ([8959b4f](https://github.com/Patternslib/dev/commit/8959b4ff9eeb7358b7d5571e7c65695d47701f85))
72
+ - Update pnpm. ([fda4f62](https://github.com/Patternslib/dev/commit/fda4f62a0f30cdc2c2991b5179bf6bc22cdd5c4d))
73
+
74
+ ## [4.4.0](https://github.com/Patternslib/dev/compare/4.3.0...4.4.0) (2026-11-05)
75
+
76
+ ### Features
77
+
78
+ - Add "update" Makefile target. ([846adbe](https://github.com/Patternslib/dev/commit/846adbe65593309cd8031a5f60f6ec3f4e139418))
79
+
80
+ `make update` will update pnpm version and project dependencies
81
+ individually and create 3 separate commits.
82
+
83
+ - Use the dependencies-update branch for make update. ([6f9523d](https://github.com/Patternslib/dev/commit/6f9523dfbd527773a4996e434fd6059daf6ce743))
84
+
85
+ ### Maintenance
86
+
87
+ - Update dependencies. ([1e805ee](https://github.com/Patternslib/dev/commit/1e805ee1486fb802c6f38afc7ef98c95f16ab5a3))
88
+ - Update dependencies. ([5a2e7c8](https://github.com/Patternslib/dev/commit/5a2e7c85e1ce628d2cb575b00acdec64f8677a82))
89
+ - Update pnpm. ([50a976b](https://github.com/Patternslib/dev/commit/50a976b082ae5978b28d9f94135084f68eb1f47c))
90
+
3
91
  ## [4.3.0](https://github.com/Patternslib/dev/compare/4.2.1...4.3.0) (2026-09-22)
4
92
 
5
93
  ### Features
package/Makefile CHANGED
@@ -1,5 +1,11 @@
1
1
  # This Makefile is meant to be exported by Patternslib or Mockup packages.
2
2
 
3
+ # Directory of this Makefile - the @patternslib/dev package directory.
4
+ # Must be set before any other include.
5
+ # Use the real path, as pnpm symlinks node_modules/@patternslib/dev into
6
+ # node_modules/.pnpm/, where its dependencies are located.
7
+ DEV_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
8
+
3
9
  # .evn include, mainly for a GITHUB_TOKEN.
4
10
  -include .env
5
11
  export
@@ -19,6 +25,15 @@ BUILDABLE := $(shell node -p "Boolean(require('./package.json').scripts?.build)"
19
25
  PACKAGE_NAME := $(shell node -p "require('./package.json').name")
20
26
  BUNDLE_NAME := $(subst @patternslib/,,$(subst @plone/,,$(PACKAGE_NAME)))
21
27
 
28
+ WEBPACK_CONFIG ?= webpack/webpack.config.js
29
+ # Resolve webpack-cli relative to @patternslib/dev. webpack is a dependency of
30
+ # @patternslib/dev and pnpm doesn't link binaries of indirect dependencies
31
+ # into the consuming project's node_modules/.bin.
32
+ WEBPACK_CLI = node $(shell node -p "require.resolve('webpack-cli/bin/cli.js', {paths: ['$(DEV_DIR)']})")
33
+
34
+ ##
35
+ ## User targets
36
+ #
22
37
 
23
38
  # Repeat this install target in consuming packages' Makefiles: on a fresh
24
39
  # checkout, @patternslib/dev and this shared Makefile are not installed yet.
@@ -26,57 +41,165 @@ BUNDLE_NAME := $(subst @patternslib/,,$(subst @plone/,,$(PACKAGE_NAME)))
26
41
  pnpm-lock.yaml install: .git/hooks/commit-msg
27
42
  $(PNPM) install
28
43
 
29
-
30
- .git/hooks/commit-msg:
31
- echo "npx commitlint --edit" > .git/hooks/commit-msg
32
- chmod u+x .git/hooks/commit-msg
33
-
44
+ # Update dependencies
45
+ # Update pnpm version and project dependencies individually and create 3 separate commits.
46
+ # Don't fail if nothing needs a commit.
47
+ .PHONY: update
48
+ update:
49
+ @if ! git diff --quiet -- package.json || ! git diff --cached --quiet -- package.json; then \
50
+ echo "Warning: package.json has uncommitted changes. Commit or stash them before running make update." >&2; \
51
+ exit 1; \
52
+ fi
53
+ @if ! git checkout -b dependencies-update; then \
54
+ echo ""; \
55
+ echo "Warning: the branch dependencies-update already exists. If it was already merged, you might want to delete if locally with \`git branch -D dependencies-update\`." >&2; \
56
+ echo ""; \
57
+ exit 1; \
58
+ fi
59
+ $(PNPM) self-update
60
+ -git commit package.json -m"maint: Update pnpm."
61
+ $(PNPM) update --latest --interactive
62
+ -git commit package.json -m"maint: Update dependencies."
63
+ -git commit pnpm-lock.yaml -m"pnpm-lock.yaml: Update." -n
34
64
 
35
65
  .PHONY: clean-dist
36
66
  clean-dist:
37
67
  rm -Rf dist/
38
68
 
39
-
40
69
  .PHONY: clean
41
70
  clean: clean-dist
42
- rm -Rf node_modules/
43
-
71
+ rm -Rf node_modules/ stats.json stats.html
44
72
 
45
- .PHONY: eslint
73
+ .PHONY: lint eslint
74
+ lint: eslint
46
75
  eslint: install
47
76
  $(ESLINT) ./src
48
77
 
49
-
50
- .PHONY: prettier
78
+ .PHONY: format prettier
79
+ format: prettier
51
80
  prettier: install
52
81
  $(PRETTIER) --write .
53
82
 
54
-
55
- .PHONY: check
83
+ # NOTE: Needs a package.json script. Not implemented here.
84
+ .PHONY: test check
85
+ test: check
56
86
  check: install eslint
57
87
  $(PNPM) run test
58
88
 
89
+ # NOTE: Needs a package.json script. Not implemented here.
90
+ .PHONY: start serve
91
+ start: serve
92
+ serve: install
93
+ $(PNPM) run start
59
94
 
60
- .PHONY: bundle-pre
61
- bundle-pre::
62
- @# Override this in your project to add some tasks before the bundle is built.
63
- @# Please use double-colons `::` so that the base bundle-pre is also run.
64
- @# Example: Unlink any linked dependencies.
65
- @# bundle-pre::
66
- @# -pnpm unlink --recursive
67
- @# pnpm install
68
- npx update-browserslist-db@latest
69
-
95
+ # NOTE: Needs a package.json script. Not implemented here.
96
+ .PHONY: watch
97
+ watch: install
98
+ $(PNPM) run watch
70
99
 
71
100
  # Compile the bundle.
101
+ # NOTE: Needs a package.json script. Not implemented here.
72
102
  # NOTE: When using the normal workflow - e.g. `make release-minor`, the
73
103
  # relase-it config runs `make bundle` after the version bump.
74
- .PHONY: bundle
104
+ .PHONY: build bundle
105
+ build: bundle
75
106
  bundle: clean-dist bundle-pre install
76
107
  ifeq ($(BUILDABLE),true)
77
108
  $(PNPM) run build
78
109
  endif
79
110
 
111
+ .PHONY: release-major
112
+ release-major:
113
+ $(MAKE) LEVEL=major release
114
+
115
+ .PHONY: release-minor
116
+ release-minor:
117
+ $(MAKE) LEVEL=minor release
118
+
119
+ .PHONY: release-patch
120
+ release-patch:
121
+ $(MAKE) LEVEL=patch release
122
+
123
+ .PHONY: prerelease-alpha
124
+ prerelease-alpha:
125
+ $(MAKE) LEVEL=alpha release
126
+
127
+ .PHONY: prerelease-beta
128
+ prerelease-beta:
129
+ $(MAKE) LEVEL=beta release
130
+
131
+
132
+ ##
133
+ ## Analyze
134
+ #
135
+
136
+ # Build stats.json. Rebuilt when pnpm-lock.yaml changes.
137
+ # Write to a temporary file first, so that a failed build doesn't leave a
138
+ # broken but up-to-date stats.json behind.
139
+ # With --json, webpack reports compilation errors only within the JSON output.
140
+ # On failure, print them before removing the temporary file.
141
+ stats.json: pnpm-lock.yaml
142
+ NODE_ENV=production $(WEBPACK_CLI) --config $(WEBPACK_CONFIG) --json > $@.tmp \
143
+ || { \
144
+ node -e "try { for (const e of JSON.parse(require('fs').readFileSync('$@.tmp')).errors || []) console.error(e.message || e) } catch {}"; \
145
+ rm -f $@.tmp; \
146
+ exit 1; \
147
+ }
148
+ mv $@.tmp $@
149
+
150
+ # Use `pnpm dlx` instead of `npx`: npx might find a package in the dependency
151
+ # tree without a linked binary and then fail with "not found".
152
+
153
+ # https://github.com/d4rkr00t/whybundled
154
+ .PHONY: analyze-bundle-dependencies
155
+ analyze-bundle-dependencies: stats.json
156
+ $(PNPM) dlx whybundled stats.json
157
+
158
+ # https://github.com/webpack/webpack-bundle-analyzer
159
+ .PHONY: analyze-bundle-treemap
160
+ analyze-bundle-treemap: stats.json
161
+ $(PNPM) dlx webpack-bundle-analyzer stats.json
162
+
163
+ # https://github.com/jonamat/webpack-visualizer
164
+ # Maintained fork of https://github.com/chrisbateman/webpack-visualizer
165
+ # The webpack plugin isn't used. Only its prebuilt frontend is downloaded,
166
+ # which renders the existing stats.json as stats.html.
167
+ VISUALIZER_PACKAGE ?= webpack-visualizer-plugin2@2
168
+ VISUALIZER_DIR := node_modules/.cache/webpack-visualizer
169
+
170
+ $(VISUALIZER_DIR)/package/lib/main.js:
171
+ mkdir -p $(VISUALIZER_DIR)
172
+ cd $(VISUALIZER_DIR) && tar -xzf "$$(npm pack --silent $(VISUALIZER_PACKAGE))"
173
+
174
+ stats.html: stats.json $(VISUALIZER_DIR)/package/lib/main.js
175
+ node $(DEV_DIR)webpack/stats-sunburst.js $(VISUALIZER_DIR)/package stats.json $@
176
+
177
+ # Command to open a file in the default browser. Override with e.g.
178
+ # `make analyze-bundle-sunburst OPEN=firefox`.
179
+ OPEN ?= $(if $(filter Darwin,$(shell uname -s)),open,xdg-open)
180
+
181
+ .PHONY: analyze-bundle-sunburst
182
+ analyze-bundle-sunburst: stats.html
183
+ $(OPEN) stats.html || echo "Open stats.html in your browser."
184
+
185
+
186
+ ##
187
+ ## Helper targets
188
+ #
189
+
190
+ .git/hooks/commit-msg:
191
+ echo "npx commitlint --edit" > .git/hooks/commit-msg
192
+ chmod u+x .git/hooks/commit-msg
193
+
194
+ .PHONY: bundle-pre
195
+ bundle-pre::
196
+ @# Override this in your project to add some tasks before the bundle is built.
197
+ @# Please use double-colons `::` so that the base bundle-pre is also run.
198
+ @# Example: Unlink any linked dependencies.
199
+ @# bundle-pre::
200
+ @# -pnpm unlink --recursive
201
+ @# pnpm install
202
+ npx update-browserslist-db@latest
80
203
 
81
204
  # Create a ZIP file from the bundle which is uploaded to the GitHub release tag.
82
205
  # NOTE: When using the normal workflow - e.g. `make release-minor`, the
@@ -92,7 +215,6 @@ ifeq ($(BUILDABLE),true)
92
215
  rm -Rf $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)
93
216
  endif
94
217
 
95
-
96
218
  # Prepare some necessary variables.
97
219
  .PHONY: prepare-release
98
220
  prepare-release:
@@ -109,14 +231,18 @@ else
109
231
  $(eval RELEASE_IT_LEVEL := $(LEVEL))
110
232
  endif
111
233
 
112
-
113
234
  # Note release-zip is run via the `after:bump` hook from .release-it.js, so
114
235
  # that the build contains the correct version bump.
115
236
  .PHONY: release
116
237
  release: clean install check prepare-release
117
238
  @# Note: The consuming package must include dist/ in its package.json files list.
118
239
 
119
- $(eval PACKAGE_VERSION := $(shell npx release-it $(RELEASE_IT_LEVEL) --release-version))
240
+ @# Get the version to be released.
241
+ @# `--release-version` implies CI mode, where release-it cannot do the
242
+ @# interactive npm login and would fail with no output if not logged in.
243
+ @# Skip the npm checks here - they are done in the real release run below.
244
+ $(eval PACKAGE_VERSION := $(shell npx release-it $(RELEASE_IT_LEVEL) --release-version --npm.skipChecks))
245
+ $(if $(PACKAGE_VERSION),,$(error Could not determine the release version via release-it))
120
246
  ifeq ($(BUILDABLE),true)
121
247
  $(eval RELEASE_IT_GITHUB_OPTIONS += --github.assets=$(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip)
122
248
  endif
@@ -133,33 +259,9 @@ endif
133
259
  -rm $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip
134
260
 
135
261
 
136
- .PHONY: release-major
137
- release-major:
138
- $(MAKE) LEVEL=major release
139
-
140
-
141
- .PHONY: release-minor
142
- release-minor:
143
- $(MAKE) LEVEL=minor release
144
-
145
-
146
- .PHONY: release-patch
147
- release-patch:
148
- $(MAKE) LEVEL=patch release
149
-
150
- .PHONY: prerelease-alpha
151
- prerelease-alpha:
152
- $(MAKE) LEVEL=alpha release
153
-
154
- .PHONY: prerelease-beta
155
- prerelease-beta:
156
- $(MAKE) LEVEL=beta release
157
-
158
-
159
- .PHONY: serve
160
- serve: install
161
- $(PNPM) run start
162
-
262
+ ##
263
+ ## Upgrades
264
+ #
163
265
 
164
266
  upgrade:\
165
267
  .git/hooks/commit-msg\
@@ -167,7 +269,6 @@ upgrade:\
167
269
  upgrade-eslint
168
270
  @# Upgrade target, depends on other upgrades
169
271
 
170
-
171
272
  upgrade-remove-husky:
172
273
  test -d .husky\
173
274
  && rm -R .husky\
@@ -176,7 +277,6 @@ upgrade-remove-husky:
176
277
  || :
177
278
  -git config --unset core.hooksPath
178
279
 
179
-
180
280
  eslint.config.js upgrade-eslint:
181
281
  test -f "eslint.config.js"\
182
282
  || (\
package/README.md CHANGED
@@ -4,6 +4,10 @@ This repository includes base files which are extended in Patternslib, Mockup or
4
4
 
5
5
  It includes a Makefile which helps in installing and releasing packages.
6
6
 
7
+ ## Updating dependencies
8
+
9
+ Run `make update` to update the dependencies in this or your dependent project.
10
+
7
11
  ## Upgrading
8
12
 
9
13
  Run `make upgrade` in your project.
package/babel.config.js CHANGED
@@ -1,8 +1,13 @@
1
+ // Resolve the preset from @patternslib/dev. Babel resolves preset names
2
+ // relative to the consuming project's config file, which might not have it
3
+ // installed - e.g. when @patternslib/dev is linked or not hoisted.
4
+ const preset_env = require.resolve("@babel/preset-env");
5
+
1
6
  module.exports = (api) => {
2
7
  let config = {
3
8
  presets: [
4
9
  [
5
- "@babel/preset-env",
10
+ preset_env,
6
11
  {
7
12
  modules: "auto",
8
13
  },
@@ -16,7 +21,7 @@ module.exports = (api) => {
16
21
  config = {
17
22
  presets: [
18
23
  [
19
- "@babel/preset-env",
24
+ preset_env,
20
25
  {
21
26
  debug: true,
22
27
  modules: false,
package/package.json CHANGED
@@ -1,38 +1,36 @@
1
1
  {
2
2
  "name": "@patternslib/dev",
3
- "version": "4.3.0",
3
+ "version": "4.5.0",
4
4
  "description": "Development base files for working with Patternslib and add-ons.",
5
5
  "license": "MIT",
6
- "packageManager": "pnpm@12.3.4",
6
+ "packageManager": "pnpm@12.23.0",
7
7
  "dependencies": {
8
- "@babel/core": "^8.0.6",
9
- "@babel/preset-env": "^8.0.6",
10
- "@commitlint/cli": "^21.2.3",
11
- "@commitlint/config-conventional": "^21.2.3",
8
+ "@babel/core": "^8.1.4",
9
+ "@babel/preset-env": "^8.1.4",
10
+ "@commitlint/cli": "^21.3.0",
11
+ "@commitlint/config-conventional": "^21.3.0",
12
12
  "@eslint/js": "^10.0.1",
13
13
  "@release-it/conventional-changelog": "^12.0.2",
14
14
  "babel-loader": "^10.1.1",
15
15
  "css-loader": "^7.1.5",
16
- "eslint": "^10.11.0",
17
- "eslint-config-prettier": "^10.1.8",
18
- "globals": "^17.12.0",
16
+ "eslint": "^10.16.0",
17
+ "eslint-config-prettier": "^10.1.9",
18
+ "globals": "^17.14.0",
19
19
  "identity-obj-proxy": "^3.0.0",
20
20
  "jest": "^30.5.2",
21
21
  "jest-environment-jsdom": "^30.5.2",
22
22
  "jest-watch-typeahead": "^3.0.1",
23
- "prettier": "^3.9.8",
23
+ "prettier": "^3.10.1",
24
24
  "regenerator-runtime": "^0.14.1",
25
- "release-it": "^21.1.0",
26
- "sass": "^1.104.1",
27
- "sass-loader": "^17.0.1",
25
+ "release-it": "^21.1.3",
26
+ "sass": "^1.108.2",
27
+ "sass-loader": "^17.1.1",
28
28
  "style-loader": "^4.0.0",
29
29
  "terser-webpack-plugin": "^5.6.1",
30
30
  "timezone-mock": "^1.4.3",
31
- "webpack": "^5.111.1",
32
- "webpack-bundle-analyzer": "^5.4.0",
33
- "webpack-cli": "^7.2.3",
34
- "webpack-dev-server": "^6.0.0",
35
- "whybundled": "^2.0.0"
31
+ "webpack": "^5.113.0",
32
+ "webpack-cli": "^7.3.1",
33
+ "webpack-dev-server": "^6.1.0"
36
34
  },
37
35
  "engines": {
38
36
  "node": "^22.18.0 || >=24.11.0"
@@ -50,12 +50,12 @@ it("builds SVG URL dependencies as files while preserving raw SVG imports", () =
50
50
  publicPath: "https://example.test/assets/",
51
51
  library: { type: "commonjs2" },
52
52
  };
53
- config.resolveLoader = {
54
- modules: [path.resolve("node_modules")],
55
- };
56
53
  // Export the CSS string instead of injecting a style tag.
54
+ // Loaders are configured with their resolved paths.
57
55
  const cssRule = config.module.rules.find(rule => rule.test.test("style.css"));
58
- cssRule.use = cssRule.use.filter(item => item.loader !== "style-loader");
56
+ cssRule.use = cssRule.use.filter(
57
+ item => item.loader !== require.resolve("style-loader"),
58
+ );
59
59
  const compiler = webpack(config);
60
60
  compiler.run((error, stats) => {
61
61
  compiler.close(closeError => {
@@ -0,0 +1,83 @@
1
+ // Render a webpack stats.json file as a sunburst chart.
2
+ //
3
+ // Uses the prebuilt, self-contained frontend of webpack-visualizer-plugin2
4
+ // (https://github.com/jonamat/webpack-visualizer, a maintained fork of
5
+ // https://github.com/chrisbateman/webpack-visualizer) without having to add
6
+ // the plugin to the webpack configuration or to install its dependencies.
7
+ //
8
+ // Usage:
9
+ // node stats-sunburst.js VISUALIZER_PACKAGE_DIR STATS_JSON OUTPUT_HTML
10
+ //
11
+ // The stats are reduced to the data which is needed by the chart. A full
12
+ // stats.json can easily be a few hundred megabytes, which is too much to be
13
+ // embedded in a HTML page.
14
+ const fs = require("fs");
15
+ const path = require("path");
16
+
17
+ const [visualizer_dir, stats_file, output_file] = process.argv.slice(2);
18
+ if (!visualizer_dir || !stats_file || !output_file) {
19
+ console.error(
20
+ "Usage: node stats-sunburst.js VISUALIZER_PACKAGE_DIR STATS_JSON OUTPUT_HTML",
21
+ );
22
+ process.exit(1);
23
+ }
24
+
25
+ const stats = JSON.parse(fs.readFileSync(stats_file, "utf8"));
26
+
27
+ // Return the modules with the fields used by the chart.
28
+ // Concatenated modules (e.g. "./src/index.js + 2 modules") are replaced by
29
+ // their individual modules, so that they show up at their real location.
30
+ const reduce_modules = (modules = []) =>
31
+ modules.flatMap((module) =>
32
+ module.modules
33
+ ? reduce_modules(module.modules)
34
+ : [
35
+ {
36
+ id: module.id,
37
+ identifier: module.identifier,
38
+ issuer: module.issuer,
39
+ index: module.index,
40
+ name: module.name,
41
+ size: module.size,
42
+ },
43
+ ],
44
+ );
45
+
46
+ const reduced_stats = {
47
+ assets: (stats.assets || []).map((asset) => ({
48
+ name: asset.name,
49
+ chunks: asset.chunks,
50
+ })),
51
+ chunks: (stats.chunks || []).map((chunk) => ({
52
+ id: chunk.id,
53
+ modules: reduce_modules(chunk.modules),
54
+ })),
55
+ modules: reduce_modules(stats.modules),
56
+ };
57
+
58
+ const read = (file) => fs.readFileSync(path.join(visualizer_dir, "lib", file), "utf8");
59
+
60
+ // Escape "<" and ">" like the original plugin, so that the stats cannot
61
+ // close the script tag.
62
+ const stats_string = JSON.stringify(reduced_stats)
63
+ .replace(/</g, "&lt;")
64
+ .replace(/>/g, "&gt;");
65
+
66
+ const html = `<!DOCTYPE html>
67
+ <html lang="en">
68
+ <head>
69
+ <meta charset="UTF-8">
70
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
71
+ <title>Webpack Visualizer - ${path.basename(path.resolve(stats_file, "../"))}</title>
72
+ <style>${read("style.css")}</style>
73
+ </head>
74
+ <body>
75
+ <div id="App"></div>
76
+ <script>window.stats = ${stats_string};</script>
77
+ <script>${read("main.js")}</script>
78
+ </body>
79
+ </html>
80
+ `;
81
+
82
+ fs.writeFileSync(output_file, html);
83
+ console.log(`Sunburst chart written to: ${path.resolve(output_file)}`);
@@ -48,32 +48,35 @@ const config_factory = (env, argv, config, babel_include = [], package_json) =>
48
48
  },
49
49
  optimization: {},
50
50
  module: {
51
+ // Loaders are resolved from @patternslib/dev and not from the
52
+ // consuming project, which might not have them installed - e.g.
53
+ // when @patternslib/dev is linked or not hoisted.
51
54
  rules: [
52
55
  {
53
56
  test: /\.js$/,
54
57
  // Exclude node modules except patternslib, pat-* and mockup packgages.
55
58
  // Allows for extending this file without needing to override for a successful webpack build.
56
59
  exclude: new RegExp(babel_exclude),
57
- loader: "babel-loader",
60
+ loader: require.resolve("babel-loader"),
58
61
  },
59
62
  {
60
63
  test: /\.(?:sass|scss|css)$/i,
61
64
  use: [
62
65
  {
63
- loader: "style-loader",
66
+ loader: require.resolve("style-loader"),
64
67
  options: {
65
68
  insert: require.resolve("./style-inserter"),
66
69
  },
67
70
  },
68
71
  {
69
- loader: "css-loader",
72
+ loader: require.resolve("css-loader"),
70
73
  options: {
71
74
  // production: false, others: loader defaults
72
75
  sourceMap: is_production ? false : undefined,
73
76
  },
74
77
  },
75
78
  {
76
- loader: "sass-loader",
79
+ loader: require.resolve("sass-loader"),
77
80
  options: {
78
81
  // production: false, others: loader defaults
79
82
  sourceMap: is_production ? false : undefined,