Skip to content

Commit 862bb98

Browse files
authored
Merge pull request #3 from Patternslib/add-version-banner
Add version banner
2 parents a89b13a + 19e5146 commit 862bb98

File tree

4 files changed

+1027
-726
lines changed

4 files changed

+1027
-726
lines changed

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@
44
"description": "Development base files for working with Patternslib and add-ons.",
55
"license": "MIT",
66
"dependencies": {
7-
"@babel/core": "^7.18.6",
8-
"@babel/eslint-parser": "^7.18.2",
9-
"@babel/preset-env": "^7.18.6",
7+
"@babel/core": "^7.18.10",
8+
"@babel/eslint-parser": "^7.18.9",
9+
"@babel/preset-env": "^7.18.10",
1010
"@commitlint/cli": "^17.0.3",
1111
"@commitlint/config-conventional": "^17.0.3",
1212
"@release-it/conventional-changelog": "^5.0.0",
1313
"babel-loader": "^8.2.5",
14-
"core-js": "3.23.3",
14+
"core-js": "3.24.1",
1515
"css-loader": "^6.7.1",
16-
"eslint": "^8.19.0",
16+
"eslint": "^8.21.0",
1717
"eslint-config-prettier": "^8.5.0",
1818
"husky": "^8.0.1",
1919
"identity-obj-proxy": "^3.0.0",
2020
"imports-loader": "^4.0.0",
21-
"jest": "^28.1.2",
22-
"jest-environment-jsdom": "^28.1.2",
23-
"jest-watch-typeahead": "^1.1.0",
21+
"jest": "^28.1.3",
22+
"jest-environment-jsdom": "^28.1.3",
23+
"jest-watch-typeahead": "^2.0.0",
2424
"prettier": "^2.7.1",
2525
"regenerator-runtime": "^0.13.9",
26-
"release-it": "^15.1.1",
27-
"sass": "^1.53.0",
26+
"release-it": "^15.3.0",
27+
"sass": "^1.54.4",
2828
"sass-loader": "^13.0.2",
2929
"style-loader": "^3.3.0",
3030
"terser-webpack-plugin": "^5.3.3",
3131
"timezone-mock": "^1.3.4",
32-
"webpack": "^5.73.0",
32+
"webpack": "^5.74.0",
3333
"webpack-bundle-analyzer": "^4.4.2",
3434
"webpack-cli": "^4.10.0",
35-
"webpack-dev-server": "^4.9.3",
35+
"webpack-dev-server": "^4.10.0",
3636
"whybundled": "^2.0.0",
3737
"yarn": "^1.22.19"
3838
},

webpack/webpack.config.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const webpack_helpers = require("./webpack-helpers");
55
// plugins
66
const TerserPlugin = require("terser-webpack-plugin");
77

8-
module.exports = (env, argv, config, babel_include = []) => {
8+
const config_factory = (env, argv, config, babel_include = [], package_json) => {
99
// Webpack config
1010

1111
// Packages in node_modules to NOT exclude from babel processing.
@@ -96,6 +96,15 @@ module.exports = (env, argv, config, babel_include = []) => {
9696
],
9797
};
9898

99+
if (package_json && package_json.version && package_json.name) {
100+
// Add a banner to generated chunks with the bundle name and version.
101+
base_config.plugins.push(
102+
new webpack.BannerPlugin({
103+
banner: `${package_json.name} ${package_json.version}`,
104+
})
105+
);
106+
}
107+
99108
// Override base_config with entries from config.
100109
// Most useful the ``entry`` entry.
101110
config = Object.assign(base_config, config);
@@ -124,14 +133,17 @@ module.exports = (env, argv, config, babel_include = []) => {
124133
new TerserPlugin({
125134
include: /(\.js$)/,
126135
extractComments: false,
127-
terserOptions: {
128-
output: {
129-
comments: false,
130-
},
131-
},
132136
}),
133137
];
134138
config.devtool = "source-map"; // Slowest option. False for no source maps.
135139
}
136140
return config;
137141
};
142+
143+
// Default export
144+
const module_exports = (module.exports = config_factory);
145+
146+
// Named exports
147+
module_exports.config = ({ env, argv, config, babel_include = [], package_json }) => {
148+
return config_factory(env, argv, config, babel_include, package_json);
149+
};

webpack/webpack.mf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function shared_from_dependencies(...dependencies) {
3333
*
3434
* Use this to extend your webpack configuration for module federation support.
3535
*
36-
* @param {String} name - Bundle/remote name. If not given, the package.json name is used.
36+
* @param {String} name - Bundle/remote name.
3737
* @param {String} remote_entry - Path to which the new remote entry file is written to.
3838
* @param {String} filename - Name of the generated remote entry file. Default ``remote.min.js``.
3939
* @param {Object} dependencies - Object with dependency name - version specifier pairs. Is used to set up the shared dependencies including their version requirements.

0 commit comments

Comments
 (0)