@patternslib/dev 4.4.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/AGENTS.md +75 -0
- package/CHANGES.md +71 -0
- package/Makefile +136 -56
- package/babel.config.js +7 -2
- package/package.json +14 -16
- package/src/webpack-assets.test.js +4 -4
- package/webpack/stats-sunburst.js +83 -0
- package/webpack/webpack.config.js +7 -4
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,76 @@
|
|
|
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
|
+
|
|
3
74
|
## [4.4.0](https://github.com/Patternslib/dev/compare/4.3.0...4.4.0) (2026-11-05)
|
|
4
75
|
|
|
5
76
|
### 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.
|
|
@@ -47,56 +62,144 @@ update:
|
|
|
47
62
|
-git commit package.json -m"maint: Update dependencies."
|
|
48
63
|
-git commit pnpm-lock.yaml -m"pnpm-lock.yaml: Update." -n
|
|
49
64
|
|
|
50
|
-
.git/hooks/commit-msg:
|
|
51
|
-
echo "npx commitlint --edit" > .git/hooks/commit-msg
|
|
52
|
-
chmod u+x .git/hooks/commit-msg
|
|
53
|
-
|
|
54
|
-
|
|
55
65
|
.PHONY: clean-dist
|
|
56
66
|
clean-dist:
|
|
57
67
|
rm -Rf dist/
|
|
58
68
|
|
|
59
|
-
|
|
60
69
|
.PHONY: clean
|
|
61
70
|
clean: clean-dist
|
|
62
|
-
rm -Rf node_modules/
|
|
63
|
-
|
|
71
|
+
rm -Rf node_modules/ stats.json stats.html
|
|
64
72
|
|
|
65
|
-
.PHONY: eslint
|
|
73
|
+
.PHONY: lint eslint
|
|
74
|
+
lint: eslint
|
|
66
75
|
eslint: install
|
|
67
76
|
$(ESLINT) ./src
|
|
68
77
|
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
.PHONY: format prettier
|
|
79
|
+
format: prettier
|
|
71
80
|
prettier: install
|
|
72
81
|
$(PRETTIER) --write .
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
.PHONY: check
|
|
83
|
+
# NOTE: Needs a package.json script. Not implemented here.
|
|
84
|
+
.PHONY: test check
|
|
85
|
+
test: check
|
|
76
86
|
check: install eslint
|
|
77
87
|
$(PNPM) run test
|
|
78
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
|
|
79
94
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
@# Example: Unlink any linked dependencies.
|
|
85
|
-
@# bundle-pre::
|
|
86
|
-
@# -pnpm unlink --recursive
|
|
87
|
-
@# pnpm install
|
|
88
|
-
npx update-browserslist-db@latest
|
|
89
|
-
|
|
95
|
+
# NOTE: Needs a package.json script. Not implemented here.
|
|
96
|
+
.PHONY: watch
|
|
97
|
+
watch: install
|
|
98
|
+
$(PNPM) run watch
|
|
90
99
|
|
|
91
100
|
# Compile the bundle.
|
|
101
|
+
# NOTE: Needs a package.json script. Not implemented here.
|
|
92
102
|
# NOTE: When using the normal workflow - e.g. `make release-minor`, the
|
|
93
103
|
# relase-it config runs `make bundle` after the version bump.
|
|
94
|
-
.PHONY: bundle
|
|
104
|
+
.PHONY: build bundle
|
|
105
|
+
build: bundle
|
|
95
106
|
bundle: clean-dist bundle-pre install
|
|
96
107
|
ifeq ($(BUILDABLE),true)
|
|
97
108
|
$(PNPM) run build
|
|
98
109
|
endif
|
|
99
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
|
|
100
203
|
|
|
101
204
|
# Create a ZIP file from the bundle which is uploaded to the GitHub release tag.
|
|
102
205
|
# NOTE: When using the normal workflow - e.g. `make release-minor`, the
|
|
@@ -112,7 +215,6 @@ ifeq ($(BUILDABLE),true)
|
|
|
112
215
|
rm -Rf $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)
|
|
113
216
|
endif
|
|
114
217
|
|
|
115
|
-
|
|
116
218
|
# Prepare some necessary variables.
|
|
117
219
|
.PHONY: prepare-release
|
|
118
220
|
prepare-release:
|
|
@@ -129,14 +231,18 @@ else
|
|
|
129
231
|
$(eval RELEASE_IT_LEVEL := $(LEVEL))
|
|
130
232
|
endif
|
|
131
233
|
|
|
132
|
-
|
|
133
234
|
# Note release-zip is run via the `after:bump` hook from .release-it.js, so
|
|
134
235
|
# that the build contains the correct version bump.
|
|
135
236
|
.PHONY: release
|
|
136
237
|
release: clean install check prepare-release
|
|
137
238
|
@# Note: The consuming package must include dist/ in its package.json files list.
|
|
138
239
|
|
|
139
|
-
|
|
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))
|
|
140
246
|
ifeq ($(BUILDABLE),true)
|
|
141
247
|
$(eval RELEASE_IT_GITHUB_OPTIONS += --github.assets=$(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip)
|
|
142
248
|
endif
|
|
@@ -153,33 +259,9 @@ endif
|
|
|
153
259
|
-rm $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip
|
|
154
260
|
|
|
155
261
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
.PHONY: release-minor
|
|
162
|
-
release-minor:
|
|
163
|
-
$(MAKE) LEVEL=minor release
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
.PHONY: release-patch
|
|
167
|
-
release-patch:
|
|
168
|
-
$(MAKE) LEVEL=patch release
|
|
169
|
-
|
|
170
|
-
.PHONY: prerelease-alpha
|
|
171
|
-
prerelease-alpha:
|
|
172
|
-
$(MAKE) LEVEL=alpha release
|
|
173
|
-
|
|
174
|
-
.PHONY: prerelease-beta
|
|
175
|
-
prerelease-beta:
|
|
176
|
-
$(MAKE) LEVEL=beta release
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
.PHONY: serve
|
|
180
|
-
serve: install
|
|
181
|
-
$(PNPM) run start
|
|
182
|
-
|
|
262
|
+
##
|
|
263
|
+
## Upgrades
|
|
264
|
+
#
|
|
183
265
|
|
|
184
266
|
upgrade:\
|
|
185
267
|
.git/hooks/commit-msg\
|
|
@@ -187,7 +269,6 @@ upgrade:\
|
|
|
187
269
|
upgrade-eslint
|
|
188
270
|
@# Upgrade target, depends on other upgrades
|
|
189
271
|
|
|
190
|
-
|
|
191
272
|
upgrade-remove-husky:
|
|
192
273
|
test -d .husky\
|
|
193
274
|
&& rm -R .husky\
|
|
@@ -196,7 +277,6 @@ upgrade-remove-husky:
|
|
|
196
277
|
|| :
|
|
197
278
|
-git config --unset core.hooksPath
|
|
198
279
|
|
|
199
|
-
|
|
200
280
|
eslint.config.js upgrade-eslint:
|
|
201
281
|
test -f "eslint.config.js"\
|
|
202
282
|
|| (\
|
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
|
-
|
|
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
|
-
|
|
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
|
+
"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.
|
|
6
|
+
"packageManager": "pnpm@12.23.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@babel/core": "^8.1.
|
|
9
|
-
"@babel/preset-env": "^8.
|
|
10
|
-
"@commitlint/cli": "^21.
|
|
11
|
-
"@commitlint/config-conventional": "^21.
|
|
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.
|
|
17
|
-
"eslint-config-prettier": "^10.1.
|
|
16
|
+
"eslint": "^10.16.0",
|
|
17
|
+
"eslint-config-prettier": "^10.1.9",
|
|
18
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.
|
|
23
|
+
"prettier": "^3.10.1",
|
|
24
24
|
"regenerator-runtime": "^0.14.1",
|
|
25
|
-
"release-it": "^21.1.
|
|
26
|
-
"sass": "^1.
|
|
27
|
-
"sass-loader": "^17.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.
|
|
32
|
-
"webpack-bundle-analyzer": "^5.4.1",
|
|
31
|
+
"webpack": "^5.113.0",
|
|
33
32
|
"webpack-cli": "^7.3.1",
|
|
34
|
-
"webpack-dev-server": "^6.1.0"
|
|
35
|
-
"whybundled": "^2.0.0"
|
|
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(
|
|
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, "<")
|
|
64
|
+
.replace(/>/g, ">");
|
|
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,
|