@patternslib/dev 4.2.0 → 4.3.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/.github/workflows/test.yml +2 -1
- package/CHANGES.md +30 -0
- package/Makefile +13 -11
- package/README.md +50 -0
- package/jest.config.js +1 -1
- package/package.json +15 -15
- package/pnpm-workspace.yaml +6 -0
- package/src/webpack-assets.test.js +92 -0
- package/webpack/webpack.config.js +16 -1
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.3.0](https://github.com/Patternslib/dev/compare/4.2.1...4.3.0) (2026-09-22)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Switch from yarn to pnpm. ([49e1ae8](https://github.com/Patternslib/dev/commit/49e1ae8979a8bdba71fbd12670b906567293aeae))
|
|
8
|
+
|
|
9
|
+
Note: This is not considered a breaking change. Depending packages
|
|
10
|
+
should not even break their development workflows.
|
|
11
|
+
|
|
12
|
+
### Maintenance
|
|
13
|
+
|
|
14
|
+
- Update minimum node version. ([e7cedaf](https://github.com/Patternslib/dev/commit/e7cedaf3f392b01ac8a5cb1c86ed97c8187617a4))
|
|
15
|
+
- Upgrade dependencies. ([413752c](https://github.com/Patternslib/dev/commit/413752cf033690da7b522ba12e127cc002815ac2))
|
|
16
|
+
|
|
17
|
+
## [4.2.1](https://github.com/Patternslib/dev/compare/4.2.0...4.2.1) (2026-09-18)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- Correct SVG file references. ([987adc3](https://github.com/Patternslib/dev/commit/987adc305acd8b59b2870e3aa3034391274b0d0e))
|
|
22
|
+
|
|
23
|
+
SVG files which are referenced in CSS/JS URL directives are now emitted
|
|
24
|
+
as separate files which can be imported via the URL directive. Raw SVG
|
|
25
|
+
imports in JavaScript files are still included as source.
|
|
26
|
+
|
|
27
|
+
This fixes an issue where SVG references in CSS files were broken.
|
|
28
|
+
|
|
29
|
+
### Maintenance
|
|
30
|
+
|
|
31
|
+
- Upgrade dependencies. ([ae2ba0f](https://github.com/Patternslib/dev/commit/ae2ba0f973042e16546becc4c0131226541e6d5b))
|
|
32
|
+
|
|
3
33
|
## [4.2.0](https://github.com/Patternslib/dev/compare/4.1.0...4.2.0) (2026-09-17)
|
|
4
34
|
|
|
5
35
|
### Features
|
package/Makefile
CHANGED
|
@@ -13,16 +13,18 @@ export
|
|
|
13
13
|
|
|
14
14
|
ESLINT ?= npx eslint
|
|
15
15
|
PRETTIER ?= npx prettier
|
|
16
|
-
|
|
16
|
+
PNPM ?= npx pnpm
|
|
17
17
|
|
|
18
18
|
BUILDABLE := $(shell node -p "Boolean(require('./package.json').scripts?.build)")
|
|
19
19
|
PACKAGE_NAME := $(shell node -p "require('./package.json').name")
|
|
20
20
|
BUNDLE_NAME := $(subst @patternslib/,,$(subst @plone/,,$(PACKAGE_NAME)))
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
# Repeat this install target in consuming packages' Makefiles: on a fresh
|
|
24
|
+
# checkout, @patternslib/dev and this shared Makefile are not installed yet.
|
|
23
25
|
.PHONY: install
|
|
24
|
-
|
|
25
|
-
$(
|
|
26
|
+
pnpm-lock.yaml install: .git/hooks/commit-msg
|
|
27
|
+
$(PNPM) install
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
.git/hooks/commit-msg:
|
|
@@ -52,7 +54,7 @@ prettier: install
|
|
|
52
54
|
|
|
53
55
|
.PHONY: check
|
|
54
56
|
check: install eslint
|
|
55
|
-
$(
|
|
57
|
+
$(PNPM) run test
|
|
56
58
|
|
|
57
59
|
|
|
58
60
|
.PHONY: bundle-pre
|
|
@@ -61,8 +63,8 @@ bundle-pre::
|
|
|
61
63
|
@# Please use double-colons `::` so that the base bundle-pre is also run.
|
|
62
64
|
@# Example: Unlink any linked dependencies.
|
|
63
65
|
@# bundle-pre::
|
|
64
|
-
@# -
|
|
65
|
-
@#
|
|
66
|
+
@# -pnpm unlink --recursive
|
|
67
|
+
@# pnpm install
|
|
66
68
|
npx update-browserslist-db@latest
|
|
67
69
|
|
|
68
70
|
|
|
@@ -72,7 +74,7 @@ bundle-pre::
|
|
|
72
74
|
.PHONY: bundle
|
|
73
75
|
bundle: clean-dist bundle-pre install
|
|
74
76
|
ifeq ($(BUILDABLE),true)
|
|
75
|
-
$(
|
|
77
|
+
$(PNPM) run build
|
|
76
78
|
endif
|
|
77
79
|
|
|
78
80
|
|
|
@@ -156,7 +158,7 @@ prerelease-beta:
|
|
|
156
158
|
|
|
157
159
|
.PHONY: serve
|
|
158
160
|
serve: install
|
|
159
|
-
$(
|
|
161
|
+
$(PNPM) run start
|
|
160
162
|
|
|
161
163
|
|
|
162
164
|
upgrade:\
|
|
@@ -170,7 +172,7 @@ upgrade-remove-husky:
|
|
|
170
172
|
test -d .husky\
|
|
171
173
|
&& rm -R .husky\
|
|
172
174
|
&& git add .husky\
|
|
173
|
-
&& git commit -m"maint: @patternslib/dev upgrade - remove .husky directory in favor of git hooks."\
|
|
175
|
+
&& git commit .husky -m"maint: @patternslib/dev upgrade - remove .husky directory in favor of git hooks."\
|
|
174
176
|
|| :
|
|
175
177
|
-git config --unset core.hooksPath
|
|
176
178
|
|
|
@@ -180,10 +182,10 @@ eslint.config.js upgrade-eslint:
|
|
|
180
182
|
|| (\
|
|
181
183
|
echo 'module.exports = require("@patternslib/dev/eslint.config.js");' > eslint.config.js\
|
|
182
184
|
&& git add eslint.config.js\
|
|
183
|
-
&& git commit -m"maint: @patternslib/dev upgrade - create eslint.config.js."\
|
|
185
|
+
&& git commit eslint.config.js -m"maint: @patternslib/dev upgrade - create eslint.config.js."\
|
|
184
186
|
)
|
|
185
187
|
test -f ".eslintrc.js"\
|
|
186
188
|
&& rm .eslintrc.js\
|
|
187
189
|
&& git add .eslintrc.js\
|
|
188
|
-
&& git commit -m"maint: @patternslib/dev upgrade - remove old .eslintrc.js."\
|
|
190
|
+
&& git commit .eslintrc.js -m"maint: @patternslib/dev upgrade - remove old .eslintrc.js."\
|
|
189
191
|
|| :
|
package/README.md
CHANGED
|
@@ -10,6 +10,56 @@ Run `make upgrade` in your project.
|
|
|
10
10
|
|
|
11
11
|
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`.
|
|
12
12
|
|
|
13
|
+
## Migrating a consuming package to pnpm
|
|
14
|
+
|
|
15
|
+
Installing `@patternslib/dev` does not require switching your project from Yarn to pnpm.
|
|
16
|
+
If you choose to migrate, update the consuming project's configuration and workflows explicitly.
|
|
17
|
+
The shared Makefile uses pnpm for installation and for running build, test, and start scripts.
|
|
18
|
+
|
|
19
|
+
1. Pin the pnpm version you intend to use and pin it in your project's `package.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
"packageManager": "pnpm@12.3.4",
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
2. Add a `pnpm-workspace.yaml` file at the project's workspace root:
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
# No nested node_modules for Module Federation.
|
|
29
|
+
shamefullyHoist: true
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
You might also want to include the following to allow to build "@patternslib/dev" and to include releases of "@patternslib/dev" which are younger than the "minimumReleaseAge":
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
allowBuilds:
|
|
36
|
+
"@patternslib/dev": true
|
|
37
|
+
|
|
38
|
+
minimumReleaseAgeExclude:
|
|
39
|
+
- "@patternslib/dev"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For more information, see the [pnpm configuration reference](https://pnpm.io/settings).
|
|
43
|
+
|
|
44
|
+
3. Change the `yarn` references in the Makefile to use `pnpm`.
|
|
45
|
+
|
|
46
|
+
```makefile
|
|
47
|
+
PNPM ?= npx pnpm
|
|
48
|
+
|
|
49
|
+
-include node_modules/@patternslib/dev/Makefile
|
|
50
|
+
|
|
51
|
+
.PHONY: install
|
|
52
|
+
pnpm-lock.yaml install:
|
|
53
|
+
$(PNPM) install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If you use `yarn link` or `yarn unlink` in your Makefile, update it to fit the new [pnpm syntax](https://pnpm.io/cli/link).
|
|
57
|
+
|
|
58
|
+
4. You might need to include pnpm to the `transformIgnorePatterns` field in Jest configuration to make the tests pass. This files `jest.setup.js` for an example.
|
|
59
|
+
|
|
60
|
+
5. Update the CI configuration to use the pnpm cache - see this projects `.github/workflows/test.yml`.
|
|
61
|
+
|
|
62
|
+
6. Run `make install`, add `pnpm-lock.yaml` to the git repository and remove `yarn.lock`.
|
|
13
63
|
|
|
14
64
|
## Code style
|
|
15
65
|
|
package/jest.config.js
CHANGED
|
@@ -17,6 +17,6 @@ module.exports = {
|
|
|
17
17
|
},
|
|
18
18
|
testEnvironment: "jsdom",
|
|
19
19
|
transformIgnorePatterns: [
|
|
20
|
-
"/node_modules/(
|
|
20
|
+
"/node_modules/(?!(?:\\.pnpm/|@patternslib/|@plone/|preact/|screenfull/)).+\\.[tj]sx?$",
|
|
21
21
|
],
|
|
22
22
|
};
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternslib/dev",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.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
7
|
"dependencies": {
|
|
7
|
-
"@babel/core": "^8.0.
|
|
8
|
-
"@babel/preset-env": "^8.0.
|
|
9
|
-
"@commitlint/cli": "^21.2.
|
|
10
|
-
"@commitlint/config-conventional": "^21.2.
|
|
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",
|
|
11
12
|
"@eslint/js": "^10.0.1",
|
|
12
13
|
"@release-it/conventional-changelog": "^12.0.2",
|
|
13
14
|
"babel-loader": "^10.1.1",
|
|
14
15
|
"css-loader": "^7.1.5",
|
|
15
|
-
"eslint": "^10.
|
|
16
|
+
"eslint": "^10.11.0",
|
|
16
17
|
"eslint-config-prettier": "^10.1.8",
|
|
17
18
|
"globals": "^17.12.0",
|
|
18
19
|
"identity-obj-proxy": "^3.0.0",
|
|
19
|
-
"jest": "^30.5.
|
|
20
|
-
"jest-environment-jsdom": "^30.5.
|
|
20
|
+
"jest": "^30.5.2",
|
|
21
|
+
"jest-environment-jsdom": "^30.5.2",
|
|
21
22
|
"jest-watch-typeahead": "^3.0.1",
|
|
22
|
-
"prettier": "^3.9.
|
|
23
|
+
"prettier": "^3.9.8",
|
|
23
24
|
"regenerator-runtime": "^0.14.1",
|
|
24
|
-
"release-it": "^21.0
|
|
25
|
+
"release-it": "^21.1.0",
|
|
25
26
|
"sass": "^1.104.1",
|
|
26
27
|
"sass-loader": "^17.0.1",
|
|
27
28
|
"style-loader": "^4.0.0",
|
|
28
29
|
"terser-webpack-plugin": "^5.6.1",
|
|
29
30
|
"timezone-mock": "^1.4.3",
|
|
30
|
-
"webpack": "^5.111.
|
|
31
|
-
"webpack-bundle-analyzer": "^5.
|
|
31
|
+
"webpack": "^5.111.1",
|
|
32
|
+
"webpack-bundle-analyzer": "^5.4.0",
|
|
32
33
|
"webpack-cli": "^7.2.3",
|
|
33
34
|
"webpack-dev-server": "^6.0.0",
|
|
34
|
-
"whybundled": "^2.0.0"
|
|
35
|
-
"yarn": "^1.22.22"
|
|
35
|
+
"whybundled": "^2.0.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
38
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"postinstall": "cd $INIT_CWD && make upgrade || true",
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const { execFileSync } = require("node:child_process");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const os = require("node:os");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
|
|
6
|
+
it("builds SVG URL dependencies as files while preserving raw SVG imports", () => {
|
|
7
|
+
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "patternslib-assets-"));
|
|
8
|
+
const svg = '<svg xmlns="http://www.w3.org/2000/svg"><path fill="#fff"/></svg>';
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
fs.writeFileSync(path.join(directory, "icon.svg"), svg);
|
|
12
|
+
fs.writeFileSync(
|
|
13
|
+
path.join(directory, "style.css"),
|
|
14
|
+
'.icon { background-image: url("./icon.svg"); }',
|
|
15
|
+
);
|
|
16
|
+
// .mjs avoids unrelated Babel processing of this small fixture.
|
|
17
|
+
fs.writeFileSync(
|
|
18
|
+
path.join(directory, "entry.mjs"),
|
|
19
|
+
`import svg from "./icon.svg";
|
|
20
|
+
import css from "./style.css";
|
|
21
|
+
export { svg };
|
|
22
|
+
export const styles = css.toString();
|
|
23
|
+
export const url = new URL("./icon.svg", import.meta.url).href;`,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Run Webpack and the generated bundle in Node, outside Jest's module
|
|
27
|
+
// transforms and CSS/SVG mocks. No browser is needed for this build.
|
|
28
|
+
const result = JSON.parse(
|
|
29
|
+
execFileSync(
|
|
30
|
+
process.execPath,
|
|
31
|
+
[
|
|
32
|
+
"-e",
|
|
33
|
+
`const path = require("node:path");
|
|
34
|
+
const webpack = require("webpack");
|
|
35
|
+
const directory = process.argv[1];
|
|
36
|
+
const config = require("./webpack/webpack.config").config({
|
|
37
|
+
config: {
|
|
38
|
+
mode: "development",
|
|
39
|
+
target: "node",
|
|
40
|
+
context: directory,
|
|
41
|
+
entry: "./entry.mjs",
|
|
42
|
+
devtool: false,
|
|
43
|
+
optimization: { minimize: false },
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
config.output = {
|
|
47
|
+
...config.output,
|
|
48
|
+
path: path.join(directory, "dist"),
|
|
49
|
+
filename: "bundle.cjs",
|
|
50
|
+
publicPath: "https://example.test/assets/",
|
|
51
|
+
library: { type: "commonjs2" },
|
|
52
|
+
};
|
|
53
|
+
config.resolveLoader = {
|
|
54
|
+
modules: [path.resolve("node_modules")],
|
|
55
|
+
};
|
|
56
|
+
// Export the CSS string instead of injecting a style tag.
|
|
57
|
+
const cssRule = config.module.rules.find(rule => rule.test.test("style.css"));
|
|
58
|
+
cssRule.use = cssRule.use.filter(item => item.loader !== "style-loader");
|
|
59
|
+
const compiler = webpack(config);
|
|
60
|
+
compiler.run((error, stats) => {
|
|
61
|
+
compiler.close(closeError => {
|
|
62
|
+
if (error || closeError) throw error || closeError;
|
|
63
|
+
if (stats.hasErrors()) throw new Error(stats.toString());
|
|
64
|
+
const result = require(path.join(directory, "dist/bundle.cjs"));
|
|
65
|
+
process.stdout.write(JSON.stringify(result));
|
|
66
|
+
});
|
|
67
|
+
});`,
|
|
68
|
+
directory,
|
|
69
|
+
],
|
|
70
|
+
{
|
|
71
|
+
cwd: path.resolve(__dirname, ".."),
|
|
72
|
+
env: { ...process.env, NODE_ENV: "test" },
|
|
73
|
+
encoding: "utf8",
|
|
74
|
+
timeout: 30000,
|
|
75
|
+
},
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(result.svg).toBe(svg);
|
|
80
|
+
const files = fs.readdirSync(path.join(directory, "dist"));
|
|
81
|
+
const svgFiles = files.filter((file) => file.endsWith(".svg"));
|
|
82
|
+
expect(svgFiles).toHaveLength(1);
|
|
83
|
+
const assetUrl = `https://example.test/assets/${svgFiles[0]}`;
|
|
84
|
+
expect(result.styles).toContain(`url(${assetUrl})`);
|
|
85
|
+
expect(result.url).toBe(assetUrl);
|
|
86
|
+
expect(fs.readFileSync(path.join(directory, "dist", svgFiles[0]), "utf8")).toBe(
|
|
87
|
+
svg,
|
|
88
|
+
);
|
|
89
|
+
} finally {
|
|
90
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
91
|
+
}
|
|
92
|
+
}, 35000);
|
|
@@ -82,9 +82,24 @@ const config_factory = (env, argv, config, babel_include = [], package_json) =>
|
|
|
82
82
|
],
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
test:
|
|
85
|
+
test: /\.(?:html|xml)$/i,
|
|
86
86
|
type: "asset/source",
|
|
87
87
|
},
|
|
88
|
+
{
|
|
89
|
+
test: /\.svg$/i,
|
|
90
|
+
oneOf: [
|
|
91
|
+
{
|
|
92
|
+
// Keep resource imports for CSS url(...) and
|
|
93
|
+
// JavaScript new URL(..., import.meta.url)
|
|
94
|
+
dependency: "url",
|
|
95
|
+
type: "asset/resource",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
// Preserve raw markup for ordinary JavaScript SVG imports.
|
|
99
|
+
type: "asset/source",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
88
103
|
{
|
|
89
104
|
test: /\.(eot|woff|woff2|ttf|png|jpe?g|gif|webp)$/i,
|
|
90
105
|
type: "asset/resource",
|