@patternslib/dev 2.0.0 → 2.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.
package/CHANGES.md CHANGED
@@ -2,6 +2,73 @@
2
2
 
3
3
 
4
4
 
5
+ ## [2.2.1](https://github.com/patternslib/dev/compare/2.2.0...2.2.1) (2022-07-06)
6
+
7
+
8
+ ### Maintenance
9
+
10
+
11
+ * Upgrade dependencies. ([41adefd](https://github.com/patternslib/dev/commit/41adefd711a2ba68ba7327236a365889b4f76205))
12
+
13
+ ## [2.2.0](https://github.com/patternslib/dev/compare/2.1.0...2.2.0) (2022-06-27)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+
19
+ * Fix missing parentheses in release-zip. ([72d435d](https://github.com/patternslib/dev/commit/72d435d500cbf9ec460bf4f5961027025e554221))
20
+
21
+
22
+ ### Breaking Changes
23
+
24
+
25
+ * **webpack module federation:** Make wepack module federation config factory more explicit. ([efd266c](https://github.com/patternslib/dev/commit/efd266cfc82372c467eb6a8b470360b72647b9bd))Change signature of the webpack mf config factory to make it simpler, more flexible and more explicit at the cost of having to pass more options.
26
+
27
+ - Remove parameters ``package_json`` and ``shared`` in favor of ``dependencies``.
28
+ - Explicitly pass all dependencies via ``dependencies``, also the base ones from @patternslib/patternslib if wanted.
29
+ - Always explicitly pass the module federation name (e.g. the package.json's package name).
30
+
31
+ This makes the MF config factory simpler although you probably have to pass more options.
32
+ You now can easily just add the dependencies you want instead of having
33
+ always @patternslib/patternslib dependencies added.
34
+
35
+
36
+ ### Maintenance
37
+
38
+
39
+ * Add [@plone](https://github.com/plone) to jest and webpack transform ignores. ([678bf09](https://github.com/patternslib/dev/commit/678bf090be043c90c462075980db5ac1a9470d39))
40
+
41
+ * Remove unnecessary import from webpack.config.js. ([6658497](https://github.com/patternslib/dev/commit/6658497746e9fd948dbbacd5ad6cfa42b98168af))
42
+
43
+ * Upgrade dependencies. ([e1e423e](https://github.com/patternslib/dev/commit/e1e423eb3371f5c4792ad246e9df8ed2d3d434d9))
44
+
45
+ ## [2.1.0](https://github.com/patternslib/dev/compare/2.0.0...2.1.0) (2022-06-25)
46
+
47
+
48
+ ### Features
49
+
50
+
51
+ * Do not build a bundle and a release-zip for @patternslib/dev. ([085a019](https://github.com/patternslib/dev/commit/085a019c16a8494a2d6fa0203d880325c996aba6))Still, we have the Makefile targets ``bundle`` and ``release-zip``
52
+ defined in the Makefile, making it possible to let other packages
53
+ include this Makefile and extend from it while it is fully functioning
54
+ for @patternslib/dev too.
55
+
56
+
57
+ ### Maintenance
58
+
59
+
60
+ * Add jquery and @patternslib/patternslib to devDependencies, so that setup_tests.js does not fail when testing this package. ([edae3f7](https://github.com/patternslib/dev/commit/edae3f771ac71f0a26e87c2e78d16e0b2aaaf122))
61
+
62
+ * Also remove eventual @plone/ from bundle name. ([7696d7d](https://github.com/patternslib/dev/commit/7696d7d2ec8dd1600dc8f2e0cdb85b8aabc44930))
63
+
64
+ * Ignore .git directory when watching for changes. ([14ff7e9](https://github.com/patternslib/dev/commit/14ff7e905794a340ce23f8afe1c77a2e20b987ca))
65
+
66
+ * Make @patternslib/patternslib a peer dependency which must be installed if e.g. the webpack.mf.js Webpack config is used. ([987b421](https://github.com/patternslib/dev/commit/987b42175acbf3fc4d2df5416dd3329b610c8116))
67
+
68
+ * Upgrade dependencies. ([7fac8d7](https://github.com/patternslib/dev/commit/7fac8d79b4ce0e3acd62861bd7bcbe3866f32adc))
69
+
70
+ * Upgrade dependencies. ([c632f09](https://github.com/patternslib/dev/commit/c632f099f0ba3b542af136feba89b28aeb457385))
71
+
5
72
  ## 2.0.0 (2022-06-15)
6
73
 
7
74
 
package/Makefile CHANGED
@@ -4,6 +4,8 @@ export
4
4
  ESLINT ?= npx eslint
5
5
  YARN ?= npx yarn
6
6
 
7
+ PACKAGE_DEV=@patternslib/dev
8
+ PACKAGE_NAME := $(shell node -p "require('./package.json').name")
7
9
 
8
10
  .PHONY: install
9
11
  stamp-yarn install:
@@ -35,7 +37,10 @@ check:: stamp-yarn eslint
35
37
 
36
38
  .PHONY: bundle
37
39
  bundle: stamp-yarn
40
+ ifneq "$(PACKAGE_NAME)" "$(PACKAGE_DEV)"
41
+ @# Do not build a bundle for @patternslib/dev
38
42
  $(YARN) run build
43
+ endif
39
44
 
40
45
 
41
46
  # If you want to release on GitHub, make sure to have a .env file with a GITHUB_TOKEN.
@@ -45,13 +50,15 @@ bundle: stamp-yarn
45
50
 
46
51
 
47
52
  release-zip: clean-dist bundle
48
- $(eval PACKAGE_NAME := $(subst @patternslib/,,$(shell node -p "require('./package.json').name")))
53
+ ifneq "$(PACKAGE_NAME)" "$(PACKAGE_DEV)"
54
+ @# Do not create a zip release for @patternslib/dev
55
+ $(eval BUNDLE_NAME := $(subst @patternslib/,,$(subst @plone/,,$(PACKAGE_NAME))))
49
56
  $(eval PACKAGE_VERSION := $(shell node -p "require('./package.json').version"))
50
- @echo name is $(PACKAGE_NAME)
51
- @echo version is $(PACKAGE_VERSION)
52
- mkdir -p dist/$(PACKAGE_NAME)-bundle-$(PACKAGE_VERSION)
53
- -mv dist/* dist/$(PACKAGE_NAME)-bundle-$(PACKAGE_VERSION)
54
- cd dist/ && zip -r $(PACKAGE_NAME)-bundle-$(PACKAGE_VERSION).zip $(PACKAGE_NAME)-bundle-$(PACKAGE_VERSION)/
57
+ @echo Creating $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip
58
+ mkdir -p dist/$(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)
59
+ -mv dist/* dist/$(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)
60
+ cd dist/ && zip -r $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)/
61
+ endif
55
62
 
56
63
 
57
64
  .PHONY: release-major
package/jest.config.js CHANGED
@@ -17,6 +17,6 @@ module.exports = {
17
17
  },
18
18
  testEnvironment: "jsdom",
19
19
  transformIgnorePatterns: [
20
- "/node_modules/(?!@patternslib/)(?!preact/)(?!screenfull/).+\\.[t|j]sx?$",
20
+ "/node_modules/(?!@patternslib/)(?!@plone/)(?!preact/)(?!screenfull/).+\\.[t|j]sx?$",
21
21
  ],
22
22
  };
package/package.json CHANGED
@@ -1,42 +1,45 @@
1
1
  {
2
2
  "name": "@patternslib/dev",
3
- "version": "2.0.0",
3
+ "version": "2.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.18.5",
7
+ "@babel/core": "^7.18.6",
8
8
  "@babel/eslint-parser": "^7.18.2",
9
- "@babel/preset-env": "^7.18.2",
10
- "@commitlint/cli": "^17.0.2",
11
- "@commitlint/config-conventional": "^17.0.2",
12
- "@patternslib/patternslib": "^9.0.0-alpha.0",
9
+ "@babel/preset-env": "^7.18.6",
10
+ "@commitlint/cli": "^17.0.3",
11
+ "@commitlint/config-conventional": "^17.0.3",
13
12
  "@release-it/conventional-changelog": "^5.0.0",
14
13
  "babel-loader": "^8.2.5",
15
- "core-js": "3.23.1",
14
+ "core-js": "3.23.3",
16
15
  "css-loader": "^6.7.1",
17
- "eslint": "^8.17.0",
16
+ "eslint": "^8.19.0",
18
17
  "eslint-config-prettier": "^8.5.0",
19
18
  "husky": "^8.0.1",
20
19
  "identity-obj-proxy": "^3.0.0",
21
20
  "imports-loader": "^4.0.0",
22
- "jest": "^28.1.1",
23
- "jest-environment-jsdom": "^28.1.1",
21
+ "jest": "^28.1.2",
22
+ "jest-environment-jsdom": "^28.1.2",
24
23
  "jest-watch-typeahead": "^1.1.0",
25
- "prettier": "^2.7.0",
24
+ "prettier": "^2.7.1",
26
25
  "regenerator-runtime": "^0.13.9",
27
- "release-it": "^15.0.0",
28
- "sass": "^1.52.3",
29
- "sass-loader": "^13.0.0",
26
+ "release-it": "^15.1.1",
27
+ "sass": "^1.53.0",
28
+ "sass-loader": "^13.0.2",
30
29
  "style-loader": "^3.3.0",
31
30
  "terser-webpack-plugin": "^5.3.3",
32
- "timezone-mock": "^1.3.2",
31
+ "timezone-mock": "^1.3.4",
33
32
  "webpack": "^5.73.0",
34
33
  "webpack-bundle-analyzer": "^4.4.2",
35
34
  "webpack-cli": "^4.10.0",
36
- "webpack-dev-server": "^4.9.2",
35
+ "webpack-dev-server": "^4.9.3",
37
36
  "whybundled": "^2.0.0",
38
37
  "yarn": "^1.22.19"
39
38
  },
39
+ "devDependencies": {
40
+ "@patternslib/patternslib": "*",
41
+ "jquery": "^3.6.0"
42
+ },
40
43
  "scripts": {
41
44
  "test": "jest"
42
45
  },
@@ -1,5 +1,4 @@
1
1
  process.traceDeprecation = true;
2
- const path = require("path");
3
2
  const webpack = require("webpack");
4
3
  const webpack_helpers = require("./webpack-helpers");
5
4
 
@@ -14,7 +13,13 @@ module.exports = (env, argv, config, babel_include = []) => {
14
13
  // babel_include, like any packages within `@patternslib`, any other
15
14
  // `pat-*` and other packges which need babel processing so that node can
16
15
  // make sense of it when compiling.
17
- babel_include = new Set(["patternslib", "pat-.*", "screenfull", ...babel_include]);
16
+ babel_include = new Set([
17
+ "@patternslib/.*",
18
+ "@plone/.*",
19
+ "pat-.*",
20
+ "screenfull",
21
+ ...babel_include,
22
+ ]);
18
23
  let babel_exclude = "";
19
24
  for (const it of babel_include) {
20
25
  babel_exclude += `(?!(${it})/)`;
@@ -110,7 +115,7 @@ module.exports = (env, argv, config, babel_include = []) => {
110
115
  config.optimization.minimize = false;
111
116
  config.devtool = "source-map"; // Slowest option. False for no source maps.
112
117
  config.watchOptions = {
113
- ignored: ["node_modules/**", "docs/**"],
118
+ ignored: ["node_modules/**", "docs/**", ".git/**"],
114
119
  };
115
120
  }
116
121
  if (process.env.NODE_ENV === "production") {
@@ -1,5 +1,4 @@
1
1
  const { ModuleFederationPlugin } = require("webpack").container;
2
- const patternslib_package_json = require("@patternslib/patternslib/package.json");
3
2
 
4
3
  // Patternslib Module Federation bundle prefix.
5
4
  // This is used to filter for module federation enabled bundles.
@@ -35,35 +34,16 @@ function shared_from_dependencies(...dependencies) {
35
34
  * Use this to extend your webpack configuration for module federation support.
36
35
  *
37
36
  * @param {String} name - Bundle/remote name. If not given, the package.json name is used.
38
- * @param {String} filename - Name of the generated remote entry file. Default ``remote.min.js``.
39
- * @param {Object} package_json - Your imported project's package.json file. This is to automatically set the shared dependencies.
40
37
  * @param {String} remote_entry - Path to which the new remote entry file is written to.
41
- * @param {Object} shared - Object with dependency name - version specifier pairs. Can be used instead of the package_json parameter.
38
+ * @param {String} filename - Name of the generated remote entry file. Default ``remote.min.js``.
39
+ * @param {Object} dependencies - Object with dependency name - version specifier pairs. Is used to set up the shared dependencies including their version requirements.
42
40
  * @returns {Object} - Webpack config partial with instantiated module federation plugins.
43
41
  */
44
- function config({
45
- name,
46
- filename = "remote.min.js",
47
- package_json,
48
- remote_entry,
49
- shared = {},
50
- }) {
51
- // If no name is given, use the package name.
52
- name = name || package_json?.name || patternslib_package_json.name;
53
-
42
+ function config({ name, remote_entry, filename = "remote.min.js", dependencies = {} }) {
54
43
  // Create a JS-variable compatible name and add a prefix.
55
44
  const normalized_bundle_name =
56
45
  MF_NAME_PREFIX + name.match(/([_$A-Za-z0-9])/g).join("");
57
46
 
58
- shared = {
59
- ...(!Object.keys(shared).length && // only include package.json depenencies, if shared is empty.
60
- shared_from_dependencies(
61
- patternslib_package_json.dependencies,
62
- package_json?.dependencies
63
- )),
64
- ...shared,
65
- };
66
-
67
47
  return new ModuleFederationPlugin({
68
48
  name: normalized_bundle_name,
69
49
  ...(remote_entry && {
@@ -72,7 +52,7 @@ function config({
72
52
  "./main": remote_entry,
73
53
  },
74
54
  }),
75
- shared: shared,
55
+ shared: shared_from_dependencies(dependencies),
76
56
  });
77
57
  }
78
58