@patternslib/dev 4.1.0 → 4.2.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.
@@ -11,9 +11,9 @@ jobs:
11
11
  name: test
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v4
15
- - uses: actions/setup-node@v4
14
+ - uses: actions/checkout@v7
15
+ - uses: actions/setup-node@v7
16
16
  with:
17
- node-version: '22'
17
+ node-version: '24'
18
18
  cache: 'yarn'
19
19
  - run: make check
package/.release-it.js CHANGED
@@ -1,18 +1,11 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const commits_template = fs
5
- .readFileSync(
6
- path.resolve(__dirname, "release-it", "conventional-changelog-commit.hbs"),
7
- )
8
- .toString();
1
+ const commitPartial = require("./release-it/conventional-changelog-commit.js");
9
2
 
10
3
  module.exports = {
11
4
  npm: {
12
5
  publish: true,
13
6
  },
14
7
  git: {
15
- requireBranch: ["master", "main", "*.x"],
8
+ requireBranch: ["master", "main", "*.x", "alpha/*", "beta/*"],
16
9
  commitMessage: "Release new version.",
17
10
  commitArgs: ["-n"],
18
11
  },
@@ -47,11 +40,14 @@ module.exports = {
47
40
  ],
48
41
  },
49
42
  writerOpts: {
50
- commitPartial: commits_template,
43
+ commitPartial,
51
44
  },
52
45
  },
53
46
  },
54
47
  hooks: {
48
+ // Format the changelog after it is written, before Git stages it.
49
+ "after:@release-it/conventional-changelog:beforeRelease":
50
+ "npx prettier --write CHANGES.md",
55
51
  // Run `make bundle` after the version is bumped to get a build with
56
52
  // the new version number comment in the entry scripts.
57
53
  // Use the make target which does a check to not build if the package
package/CHANGES.md CHANGED
@@ -1,6 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.2.1](https://github.com/Patternslib/dev/compare/4.2.0...4.2.1) (2026-09-18)
3
4
 
5
+ ### Bug Fixes
6
+
7
+ - Correct SVG file references. ([987adc3](https://github.com/Patternslib/dev/commit/987adc305acd8b59b2870e3aa3034391274b0d0e))
8
+
9
+ SVG files which are referenced in CSS/JS URL directives are now emitted
10
+ as separate files which can be imported via the URL directive. Raw SVG
11
+ imports in JavaScript files are still included as source.
12
+
13
+ This fixes an issue where SVG references in CSS files were broken.
14
+
15
+ ### Maintenance
16
+
17
+ - Upgrade dependencies. ([ae2ba0f](https://github.com/Patternslib/dev/commit/ae2ba0f973042e16546becc4c0131226541e6d5b))
18
+
19
+ ## [4.2.0](https://github.com/Patternslib/dev/compare/4.1.0...4.2.0) (2026-09-17)
20
+
21
+ ### Features
22
+
23
+ - Format the changelog after generation. ([8477b72](https://github.com/Patternslib/dev/commit/8477b721dfd7db18aeeefe9e9c5ce2620bbeed89))
24
+
25
+ Use prettier to format the changelog after changelog generation.
26
+
27
+ Co-authored-by: Codex <noreply@openai.com>
28
+
29
+ - Optimize the source map options. ([d60d03f](https://github.com/Patternslib/dev/commit/d60d03f5432d2cef8926538eaf65bf431c210ab4))
30
+
31
+ Change the source map options for production and development builds for
32
+ a better compromise on bundle size, build speed and debugability.
33
+
34
+ - Upgrade to babel version 8, only targeting ES6+ browsers. ([228bf05](https://github.com/Patternslib/dev/commit/228bf057eb1f97d05ca85e2b22cadaf891abedd0))
35
+
36
+ ES6 browsers are a baseline since 2017, so this change can be considered
37
+ safe and now a breaking change.
38
+
39
+ ### Maintenance
40
+
41
+ - Allow releases from alpha/* and beta/* branches, alongside to master, main and *.x. ([73c49fa](https://github.com/Patternslib/dev/commit/73c49fa2cb7d797626411da76f3b702f8e03a960))
42
+ - Migrate handlebars changelog template to JavaScript render functions. ([a1685f9](https://github.com/Patternslib/dev/commit/a1685f9d84e7e36c6d2c1cc6426b454228ddf15d))
43
+
44
+ Co-authored-by: Codex <noreply@openai.com>
45
+
46
+ - Update dependencies. ([c9e6d18](https://github.com/Patternslib/dev/commit/c9e6d181fb33fb165fd1dae3cec75ef6e65a3ec6))
47
+ - Update GitHub workflow environment. ([3261bd3](https://github.com/Patternslib/dev/commit/3261bd3f8d3b0b8f5f0f4dc2138f174d26d86b8a))
48
+ - Upgrade commitlint and release-it to v21. ([cdea75f](https://github.com/Patternslib/dev/commit/cdea75f9859641046dcc45832c650630012b6df3))
4
49
 
5
50
  ## [4.1.0](https://github.com/Patternslib/dev/compare/4.1.0-alpha.0...4.1.0) (2026-09-16)
6
51
 
@@ -8,34 +53,31 @@
8
53
 
9
54
  ### Features
10
55
 
56
+ - **module federation:** resolve a promise once all remote bundles are initialized ([e2f0f22](https://github.com/Patternslib/dev/commit/e2f0f22d6433960ddd297fd15e53f752a30a9486))
11
57
 
12
- * **module federation:** resolve a promise once all remote bundles are initialized ([e2f0f22](https://github.com/Patternslib/dev/commit/e2f0f22d6433960ddd297fd15e53f752a30a9486))
13
-
14
- The document-ready handler started the initialization of all Module
15
- Federation remote bundles but did not wait for them: the
16
- ``patternslib__mf--loaded`` event fired before any remote had actually
17
- loaded and run its main module. Consumers had no way to know when the
18
- remotes' patterns and components were registered.
58
+ The document-ready handler started the initialization of all Module
59
+ Federation remote bundles but did not wait for them: the
60
+ `patternslib__mf--loaded` event fired before any remote had actually
61
+ loaded and run its main module. Consumers had no way to know when the
62
+ remotes' patterns and components were registered.
19
63
 
20
64
  The helper now initializes all remotes in parallel, waits for all of
21
65
  them to settle (a failing remote is logged and does not block the
22
66
  others), and only then dispatches the event. The new promise
23
- ``window.__patternslib_mf_initialized`` is created at module load time,
67
+ `window.__patternslib_mf_initialized` is created at module load time,
24
68
  so it can be awaited by code running before or after document ready —
25
69
  the Patternslib registry uses it to defer the initial DOM scan.
26
70
 
27
- A remote's main module usually only does ``import("./bundle")`` — the
71
+ A remote's main module usually only does `import("./bundle")` — the
28
72
  async boundary needed to consume shared modules — and the registrations
29
73
  happen in that chunk. If the main module exports that promise as its
30
- default export (``export default import("./bundle")``), the helper
74
+ default export (`export default import("./bundle")`), the helper
31
75
  waits for it as well. Remotes without the export keep working as
32
76
  before.
33
77
 
34
-
35
78
  ### Bug Fixes
36
79
 
37
-
38
- * Cleanup changelog entries. ([c311b84](https://github.com/Patternslib/dev/commit/c311b84d22c3c10721525d3c56423d7a200d4450))
80
+ - Cleanup changelog entries. ([c311b84](https://github.com/Patternslib/dev/commit/c311b84d22c3c10721525d3c56423d7a200d4450))
39
81
 
40
82
  ## [4.0.2](https://github.com/Patternslib/dev/compare/4.0.1...4.0.2) (2026-09-05)
41
83
 
package/babel.config.js CHANGED
@@ -1,31 +1,29 @@
1
- module.exports = (env) => {
1
+ module.exports = (api) => {
2
2
  let config = {
3
3
  presets: [
4
4
  [
5
5
  "@babel/preset-env",
6
6
  {
7
- useBuiltIns: "entry",
8
- corejs: 3,
7
+ modules: "auto",
9
8
  },
10
9
  ],
11
10
  ],
12
11
  };
13
12
 
14
13
  // passed via NODE_ENV=development environment variable.
15
- if (env.env() === "development") {
14
+ if (api.env() === "development") {
16
15
  // For development, do less transformations for better readability.
17
16
  config = {
18
17
  presets: [
19
18
  [
20
19
  "@babel/preset-env",
21
20
  {
22
- modules: false,
23
21
  debug: true,
24
- useBuiltIns: false,
25
- targets: "last 1 Chrome version, last 1 Firefox version",
22
+ modules: false,
26
23
  },
27
24
  ],
28
25
  ],
26
+ targets: "last 1 Chrome version, last 1 Firefox version",
29
27
  };
30
28
  }
31
29
 
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
2
  "name": "@patternslib/dev",
3
- "version": "4.1.0",
3
+ "version": "4.2.1",
4
4
  "description": "Development base files for working with Patternslib and add-ons.",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@babel/core": "^7.29.0",
8
- "@babel/preset-env": "^7.29.2",
9
- "@commitlint/cli": "^20.5.0",
10
- "@commitlint/config-conventional": "^20.5.0",
7
+ "@babel/core": "^8.0.6",
8
+ "@babel/preset-env": "^8.0.6",
9
+ "@commitlint/cli": "^21.2.2",
10
+ "@commitlint/config-conventional": "^21.2.2",
11
11
  "@eslint/js": "^10.0.1",
12
- "@release-it/conventional-changelog": "^10.0.6",
12
+ "@release-it/conventional-changelog": "^12.0.2",
13
13
  "babel-loader": "^10.1.1",
14
- "css-loader": "^7.1.4",
15
- "eslint": "^10.2.1",
14
+ "css-loader": "^7.1.5",
15
+ "eslint": "^10.11.0",
16
16
  "eslint-config-prettier": "^10.1.8",
17
- "globals": "^17.5.0",
17
+ "globals": "^17.12.0",
18
18
  "identity-obj-proxy": "^3.0.0",
19
- "jest": "^30.3.0",
20
- "jest-environment-jsdom": "^30.3.0",
19
+ "jest": "^30.5.2",
20
+ "jest-environment-jsdom": "^30.5.2",
21
21
  "jest-watch-typeahead": "^3.0.1",
22
- "prettier": "^3.8.3",
22
+ "prettier": "^3.9.8",
23
23
  "regenerator-runtime": "^0.14.1",
24
- "release-it": "^20.0.0",
25
- "sass": "^1.99.0",
26
- "sass-loader": "^16.0.7",
24
+ "release-it": "^21.1.0",
25
+ "sass": "^1.104.1",
26
+ "sass-loader": "^17.0.1",
27
27
  "style-loader": "^4.0.0",
28
- "terser-webpack-plugin": "^5.4.0",
29
- "timezone-mock": "^1.4.2",
30
- "webpack": "^5.106.2",
31
- "webpack-bundle-analyzer": "^5.3.0",
32
- "webpack-cli": "^7.0.2",
33
- "webpack-dev-server": "^5.2.3",
28
+ "terser-webpack-plugin": "^5.6.1",
29
+ "timezone-mock": "^1.4.3",
30
+ "webpack": "^5.111.1",
31
+ "webpack-bundle-analyzer": "^5.3.3",
32
+ "webpack-cli": "^7.2.3",
33
+ "webpack-dev-server": "^6.0.0",
34
34
  "whybundled": "^2.0.0",
35
35
  "yarn": "^1.22.22"
36
36
  },
@@ -0,0 +1,45 @@
1
+ // The preset adds the list marker and indents continuation lines.
2
+ module.exports = function commitPartial(context, commit) {
3
+ const repoUrl = context.repository
4
+ ? [context.host, context.owner, context.repository].filter(Boolean).join("/")
5
+ : context.repoUrl;
6
+ const summary = [
7
+ commit.scope && `**${commit.scope}:**`,
8
+ commit.subject || commit.header,
9
+ commit.hash &&
10
+ (context.linkReferences
11
+ ? `([${commit.shortHash}](${repoUrl}/${context.commit}/${commit.hash}))`
12
+ : commit.hash),
13
+ ]
14
+ .filter(Boolean)
15
+ .join(" ");
16
+
17
+ const references = (commit.references || []).map((reference) => {
18
+ const label = `${reference.owner ? `${reference.owner}/` : ""}${reference.repository || ""}#${reference.issue}`;
19
+ if (!context.linkReferences) {
20
+ return label;
21
+ }
22
+
23
+ const referenceUrl = context.repository
24
+ ? [
25
+ context.host,
26
+ reference.repository
27
+ ? reference.owner || context.owner
28
+ : context.owner,
29
+ reference.repository || context.repository,
30
+ ]
31
+ .filter(Boolean)
32
+ .join("/")
33
+ : context.repoUrl;
34
+ return `[${label}](${referenceUrl}/${context.issue}/${reference.issue})`;
35
+ });
36
+
37
+ return [
38
+ summary,
39
+ commit.body,
40
+ commit.footer,
41
+ references.length && `closes ${references.join(" ")}`,
42
+ ]
43
+ .filter(Boolean)
44
+ .join("\n\n");
45
+ };
@@ -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);
@@ -25,6 +25,9 @@ const config_factory = (env, argv, config, babel_include = [], package_json) =>
25
25
  }
26
26
  babel_exclude = `node_modules/${babel_exclude}.*`;
27
27
 
28
+ const is_development = process.env.NODE_ENV === "development";
29
+ const is_production = process.env.NODE_ENV === "production";
30
+
28
31
  const base_config = {
29
32
  entry: {}, // Entry point files for your JavaScript application.
30
33
  externals: [
@@ -62,14 +65,41 @@ const config_factory = (env, argv, config, babel_include = [], package_json) =>
62
65
  insert: require.resolve("./style-inserter"),
63
66
  },
64
67
  },
65
- "css-loader",
66
- "sass-loader",
68
+ {
69
+ loader: "css-loader",
70
+ options: {
71
+ // production: false, others: loader defaults
72
+ sourceMap: is_production ? false : undefined,
73
+ },
74
+ },
75
+ {
76
+ loader: "sass-loader",
77
+ options: {
78
+ // production: false, others: loader defaults
79
+ sourceMap: is_production ? false : undefined,
80
+ },
81
+ },
67
82
  ],
68
83
  },
69
84
  {
70
- test: /\.*(?:html|xml|svg)$/i,
85
+ test: /\.(?:html|xml)$/i,
71
86
  type: "asset/source",
72
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
+ },
73
103
  {
74
104
  test: /\.(eot|woff|woff2|ttf|png|jpe?g|gif|webp)$/i,
75
105
  type: "asset/resource",
@@ -101,7 +131,7 @@ const config_factory = (env, argv, config, babel_include = [], package_json) =>
101
131
  // Most useful the ``entry`` entry.
102
132
  config = Object.assign(base_config, config);
103
133
 
104
- if (process.env.NODE_ENV === "development") {
134
+ if (is_development) {
105
135
  // Add a dev server.
106
136
  config.devServer = {
107
137
  static: {
@@ -113,13 +143,21 @@ const config_factory = (env, argv, config, babel_include = [], package_json) =>
113
143
  "Access-Control-Allow-Origin": "*",
114
144
  },
115
145
  };
146
+
147
+ if (config.devtool === undefined) {
148
+ // Build: slow, rebuild: fast - good compromise for development
149
+ // debuggability.
150
+ // Set to `false` for no source maps.
151
+ config.devtool = "eval-cheap-module-source-map";
152
+ }
153
+
116
154
  config.optimization.minimize = false;
117
- config.devtool = "source-map"; // Slowest option. False for no source maps.
118
155
  config.watchOptions = {
119
156
  ignored: ["node_modules/**", "docs/**", ".git/**"],
120
157
  };
121
158
  }
122
- if (process.env.NODE_ENV === "production") {
159
+
160
+ if (is_production) {
123
161
  // Minify all JS files in production mode.
124
162
  config.optimization.minimizer = [
125
163
  new TerserPlugin({
@@ -127,7 +165,13 @@ const config_factory = (env, argv, config, babel_include = [], package_json) =>
127
165
  extractComments: false,
128
166
  }),
129
167
  ];
130
- config.devtool = "source-map"; // Slowest option. False for no source maps.
168
+
169
+ if (config.devtool === undefined) {
170
+ // Build: slowest, rebuild: slowest - Reduce bundle size but allow
171
+ // tracebacks with original line numbers.
172
+ // Set to `false` for no source maps.
173
+ config.devtool = "nosources-source-map";
174
+ }
131
175
  }
132
176
  return config;
133
177
  };
@@ -1,72 +0,0 @@
1
-
2
- *{{#if scope}} **{{scope}}:**
3
- {{~/if}} {{#if subject}}
4
- {{~subject}}
5
- {{~else}}
6
- {{~header}}
7
- {{~/if}}
8
-
9
- {{~!-- commit link --}} {{#if @root.linkReferences~}}
10
- ([{{shortHash}}](
11
- {{~#if @root.repository}}
12
- {{~#if @root.host}}
13
- {{~@root.host}}/
14
- {{~/if}}
15
- {{~#if @root.owner}}
16
- {{~@root.owner}}/
17
- {{~/if}}
18
- {{~@root.repository}}
19
- {{~else}}
20
- {{~@root.repoUrl}}
21
- {{~/if}}/
22
- {{~@root.commit}}/{{hash}}))
23
- {{~else}}
24
- {{~hash}}
25
- {{~/if}}
26
-
27
- {{#if body}}
28
-
29
- {{body}}
30
- {{/if}}
31
- {{#if footer}}
32
-
33
- {{footer}}
34
- {{/if}}
35
-
36
- {{~!-- commit references --}}
37
- {{~#if references~}}
38
-
39
- closes
40
- {{~#each references}} {{#if @root.linkReferences~}}
41
- [
42
- {{~#if this.owner}}
43
- {{~this.owner}}/
44
- {{~/if}}
45
- {{~this.repository}}#{{this.issue}}](
46
- {{~#if @root.repository}}
47
- {{~#if @root.host}}
48
- {{~@root.host}}/
49
- {{~/if}}
50
- {{~#if this.repository}}
51
- {{~#if this.owner}}
52
- {{~this.owner}}/
53
- {{~/if}}
54
- {{~this.repository}}
55
- {{~else}}
56
- {{~#if @root.owner}}
57
- {{~@root.owner}}/
58
- {{~/if}}
59
- {{~@root.repository}}
60
- {{~/if}}
61
- {{~else}}
62
- {{~@root.repoUrl}}
63
- {{~/if}}/
64
- {{~@root.issue}}/{{this.issue}})
65
- {{~else}}
66
- {{~#if this.owner}}
67
- {{~this.owner}}/
68
- {{~/if}}
69
- {{~this.repository}}#{{this.issue}}
70
- {{~/if}}{{/each}}
71
- {{~/if}}
72
-