Skip to content

Commit bd54db0

Browse files
committed
added color verbose output via ANSI color library - ansis
added the test case for styles imported from javascript
1 parent 6f5119e commit bd54db0

File tree

34 files changed

+149
-178
lines changed

34 files changed

+149
-178
lines changed

.codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 90%
6+
patch:
7+
default:
8+
target: 90%
9+
10+
ignore:
11+
- test/.*
File renamed without changes.

CHANGELOG.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,76 @@
1-
## 0.7.2 (Dec 13, 2021) The last stable version
2-
- add new option `enable` to enable / disable the plugin, e.g. by development
3-
- add support of `RegExp` for option `extensions`
1+
## 0.7.3 (Jan 30, 2022) The last stable version
2+
- added color verbose output via ANSI color library - ansis
3+
- added the test case for styles imported from javascript
4+
5+
## 0.7.2 (Dec 13, 2021)
6+
- added new option `enable` to enable / disable the plugin, e.g. by development
7+
- added supports of `RegExp` for option `extensions`
48
- remove deprecated option `silent`, use `verbose` to show process information (no braking change)
5-
- add GitHub workflow + codecov
6-
- color verbose output
9+
- added GitHub workflow + codecov
710
- update packages
811
- update readme
912

1013
## 0.7.1 (Jan 14, 2021)
1114
### Bugfixes
12-
- The issue infinite recursion by collect of resources from dependency modules by usage in react app some big components with many thousands dependencies.
15+
- fix the issue infinite recursion by collect of resources from dependency modules by usage in react app some big components with many thousands dependencies
1316

1417
## 0.7.0 (Dec 21, 2020)
1518
### Breaking change
16-
- The `silent` option is deprecated and will be removed on Juni 30, 2021. Use option `verbose: true` to show in console each removed empty file. Defaults, `verbose: false`.
19+
- deprecate the `silent` option, it will be removed on Juni 30, 2021. Use option `verbose: true` to show in console each removed empty file. Defaults, `verbose: false`.
1720

1821
### Bugfixes
19-
- The issue `Maximum call stack size exceeded` was general fixed in all cases, for example, by usage the webpack setting `optimization.concatenateModules: true` and:
22+
- fix issue `Maximum call stack size exceeded` in all cases, for example, by usage the webpack setting `optimization.concatenateModules: true` and:
2023
- import react
2124
- import redux
2225
- webpack setting `externals.jquery: 'jQuery'` or other external libs
2326
- The issue if first in webpack entries are a styles and then a scripts.
2427

2528
## 0.6.4 (Dec 19, 2020)
26-
- Bugfix the error: `Maximum call stack size exceeded` with webpack setting `optimization.concatenateModules: true`and usage in script imports from `react` and `redux`.
27-
- Add test case for single style without a scripts in webpack config.
28-
- Add silent mode in tests to suppress output log info in the console.
29-
- The option `ignore` can be the array of string or RegExp. Add default value of `ignore` as `['/node_modules/']` to ignore resources from `node_modules` path.
30-
- Update npm packages.
29+
- fix the error: `Maximum call stack size exceeded` with webpack setting `optimization.concatenateModules: true`and usage in script imports from `react` and `redux`
30+
- added the test case for single style without a scripts in webpack config
31+
- added silent mode in tests to suppress output log info in the console
32+
- improve the option `ignore`:
33+
- it can be the array of string or RegExp
34+
- added default value of `ignore` as `['/node_modules/']` to ignore resources from `node_modules` path
35+
- update npm packages.
3136

3237
## 0.6.3 (Oct 25, 2020)
33-
Fix BREAKING CHANGE in Webpack 5: No more changes should happen to `Compilation.assets`. Update code accord new API.
38+
- fix BREAKING CHANGE in Webpack 5: no more changes should happen to `Compilation.assets`
39+
- update code accord new API
3440

3541
## 0.6.2 (Oct 24, 2020)
3642
Update npm packages.
3743

3844
## 0.6.1 (Oct 20, 2020)
39-
The fork of original `https://github.com/fqborges/webpack-fix-style-only-entries` (ver. 0.6.0) for support only Webpack 5 and above.
45+
The fork of original [webpack-fix-style-only-entries](https://github.com/fqborges/webpack-fix-style-only-entries) (ver. 0.6.0) for support only Webpack 5 and above.
4046
The Webpack 4 is no longer supported.
4147

42-
The changes from original version 0.6.0:
48+
### The changes from original version 0.6.0:
4349

44-
- Added the feature: considers the use hash after the .js and .mjs extension in file format like `.js?[hash]` or `.mjs?[hash]`.
45-
The idea and requirement belong to https://github.com/MatiasMorici from PR https://github.com/fqborges/webpack-fix-style-only-entries/pull/27/commits/57eeecbcb85926578770c3845465e4012b02a196
50+
- feature: considers the use hash after the .js and .mjs extension in file format like `.js?[hash]` or `.mjs?[hash]`.
51+
The idea and requirement belong to [MatiasMorici](https://github.com/MatiasMorici) from [PR](https://github.com/fqborges/webpack-fix-style-only-entries/pull/27/commits/57eeecbcb85926578770c3845465e4012b02a196)
4652
- In Webpack 5 fixed deprecation messages:
4753
- DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE
4854
- DEP_WEBPACK_CHUNK_ENTRY_MODULE
4955
- DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET
5056
- DEP_WEBPACK_MODULE_INDEX
5157

52-
- Update all packages for Webpack 5.
53-
- Fix integration test script for using with Webpack 5.
54-
- Fix a BUG of `terser-webpack-plugin` (generate the futile file `vendor.js.LICENSE.txt`) in the production test `vendor+multi-js-entry-css-entry`.
55-
- Fix module structure in README.md.
58+
- update all packages for Webpack 5.
59+
- fix integration test script for using with Webpack 5.
60+
- fix a BUG of `terser-webpack-plugin` (generate the futile file `vendor.js.LICENSE.txt`) in the production test `vendor+multi-js-entry-css-entry`.
61+
- fix module structure in README.md.
5662

5763
## 0.6.0 (Oct 13, 2020)
5864
Being overly careful here, this version is not breaking for almost all the existing users. It could possibly break in some edge cases, since it changes how modules are collected (from global to one each compilation) or if you have a workaround for a working webpack multi configuration.
5965
- BREAKING (POSSIBLY): Use a dedicated cache for every compilation (Prevent arbitrary files deletion when using Webpack with multi configurations) (PR [#39](https://github.com/fqborges/webpack-fix-style-only-entries/pull/39))
6066

6167
## 0.5.2 (Oct 07, 2020)
62-
- Webpack 5 support using ModuleGraph API (PR [#38](https://github.com/fqborges/webpack-fix-style-only-entries/pull/38))
68+
- supports Webpack 5 using ModuleGraph API (PR [#38](https://github.com/fqborges/webpack-fix-style-only-entries/pull/38))
6369
- npm audit fix: ([ea9dd7](https://github.com/fqborges/webpack-fix-style-only-entries/commit/ea9dd7bd7ade5b16623064a4850de39545e1e18e))
6470

6571
## 0.5.1 (Jun 13, 2020)
66-
- Fix Maximum call stack size exceeded (PR [#34](https://github.com/fqborges/webpack-fix-style-only-entries/pull/34))
67-
- Added CHANGELOG ([3e3767](https://github.com/fqborges/webpack-fix-style-only-entries/commit/3e3767d8998a53d807b5d5b10643d05b800aa79a))
72+
- fix Maximum call stack size exceeded (PR [#34](https://github.com/fqborges/webpack-fix-style-only-entries/pull/34))
73+
- added CHANGELOG ([3e3767](https://github.com/fqborges/webpack-fix-style-only-entries/commit/3e3767d8998a53d807b5d5b10643d05b800aa79a))
6874

6975
## 0.5.0 (May 18, 2020)
7076
- fix for [#23](https://github.com/fqborges/webpack-fix-style-only-entries/issues/23) ([37d350](https://github.com/fqborges/webpack-fix-style-only-entries/commit/37d350eec83f49c0b12729a93aa6cf2f96d92d0b))

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![npm version](https://badgen.net/npm/v/webpack-remove-empty-scripts/0.7.2/)](https://www.npmjs.com/package/webpack-remove-empty-scripts/v/0.7.2)
1+
[![npm](https://img.shields.io/npm/v/webpack-remove-empty-scripts/latest?logo=npm&color=brightgreen "npm package")](https://www.npmjs.com/package/webpack-remove-empty-scripts/v/0.7.3)
22
[![node](https://img.shields.io/node/v/webpack-remove-empty-scripts)](https://nodejs.org)
33
[![node](https://img.shields.io/github/package-json/dependency-version/webdiscus/webpack-remove-empty-scripts/peer/webpack)](https://webpack.js.org/)
44
[![codecov](https://codecov.io/gh/webdiscus/webpack-remove-empty-scripts/branch/master/graph/badge.svg)](https://codecov.io/gh/webdiscus/webpack-remove-empty-scripts)
@@ -44,7 +44,7 @@ You can find more info by the following issues:
4444
> Please test your project before using it in production.\
4545
> If you have a problem with the new version, please create a [new issue](https://github.com/webdiscus/webpack-remove-empty-scripts/issues).
4646
47-
> :warning: The last stable release is `0.7.2` in the branch [`stable`](https://github.com/webdiscus/webpack-remove-empty-scripts/tree/stable).
47+
> :warning: The last stable release is `0.7.3` in the branch [`stable`](https://github.com/webdiscus/webpack-remove-empty-scripts/tree/stable).
4848
4949
## Propose
5050
If you use the `mini-css-extract-plugin` only to extract `css` files from styles defined in webpack entry
@@ -192,13 +192,15 @@ new RemoveEmptyScriptsPlugin({
192192
## Also See
193193

194194
- more examples of usages see in [test cases](https://github.com/webdiscus/webpack-remove-empty-scripts/tree/master/test/cases)
195-
- [`pug-plugin`][pug-plugin]
196-
- [`pug-loader`][pug-loader]
195+
- [ansis][ansis] - ANSI color styling of text in terminal
196+
- [pug-plugin][pug-plugin]
197+
- [pug-loader][pug-loader]
197198

198199
## License
199200
[ISC](https://github.com/webdiscus/webpack-remove-empty-scripts/blob/master/LICENSE)
200201

201202
<!-- prettier-ignore-start -->
203+
[ansis]: https://github.com/webdiscus/ansis
202204
[pug-plugin]: https://github.com/webdiscus/pug-plugin
203205
[pug-loader]: https://github.com/webdiscus/pug-loader
204206
<!-- prettier-ignore-end -->

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-remove-empty-scripts",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"description": "Webpack 5 plugin to remove empty scripts generated by usage only styles in webpack entry.",
55
"keywords": [
66
"webpack",
@@ -13,8 +13,8 @@
1313
"sass",
1414
"css",
1515
"js",
16-
"mini-css-extract-plugin",
17-
"webpack-fix-style-only-entries"
16+
"entry",
17+
"css-extract"
1818
],
1919
"license": "ISC",
2020
"author": "webdiscus (https://github.com/webdiscus)",
@@ -63,20 +63,22 @@
6363
"peerDependencies": {
6464
"webpack": ">=5.32.0"
6565
},
66-
"dependencies": {},
66+
"dependencies": {
67+
"ansis": "^1.3.4"
68+
},
6769
"devDependencies": {
68-
"@babel/core": "^7.16.0",
69-
"@babel/preset-env": "^7.16.4",
70-
"@types/jest": "^27.0.3",
70+
"@babel/core": "^7.16.12",
71+
"@babel/preset-env": "^7.16.11",
72+
"@types/jest": "^27.4.0",
7173
"css-loader": "^6.5.1",
7274
"fs": "^0.0.1-security",
73-
"html-loader": "^3.0.1",
74-
"jest": "^27.4.4",
75-
"mini-css-extract-plugin": "^2.4.5",
75+
"html-loader": "^3.1.0",
76+
"jest": "^27.4.7",
77+
"mini-css-extract-plugin": "^2.5.3",
7678
"moment": "^2.29.1",
7779
"rimraf": "^3.0.2",
78-
"terser-webpack-plugin": "^5.2.5",
79-
"webpack": "^5.65.0",
80+
"terser-webpack-plugin": "^5.3.0",
81+
"webpack": "^5.67.0",
8082
"webpack-hot-middleware": "^2.25.1",
8183
"webpack-merge": "^5.8.0"
8284
}

src/color-string.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
const path = require('path');
6-
const colstr = require('./color-string');
6+
const ansis = require('ansis');
77

88
const plugin = 'remove-empty-scripts';
99
const defaultOptions = {
@@ -55,7 +55,7 @@ class WebpackRemoveEmptyScriptsPlugin {
5555
for (const module of chunkGraph.getChunkEntryModulesIterable(chunk)) {
5656
if (!compilation.modules.has(module)) {
5757
throw new Error(
58-
`${plugin} checkConstraints: entry module in chunk but not in compilation ${chunk.debugId} ${module.debugId}`
58+
`\n${ansis.black.bgRed(`[${plugin}]`)} entry module in chunk but not in compilation ${chunk.debugId} ${module.debugId}`
5959
);
6060
}
6161

@@ -74,7 +74,7 @@ class WebpackRemoveEmptyScriptsPlugin {
7474
if (this.verbose) {
7575
const outputFile = path.join(outputPath, filename);
7676
console.log(
77-
` ${colstr.bgYellow(` ${plugin} `, colstr.colors.black)} remove ${colstr.cyan(outputFile)}`,
77+
`${ansis.black.bgYellow(`[${plugin}]`)} remove ${ansis.cyan(outputFile)}`,
7878
);
7979
}
8080

test/cases/css-entry-only/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const WebpackRemoveEmptyScripts = require('../../../src/index.js');
1+
const RemoveEmptyScriptsPlugin = require('../../../src/index.js');
22

33
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
44

@@ -16,7 +16,7 @@ module.exports = {
1616
],
1717
},
1818
plugins: [
19-
new WebpackRemoveEmptyScripts({
19+
new RemoveEmptyScriptsPlugin({
2020
enabled: true,
2121
verbose: true,
2222
}),

test/cases/css-entry-with-ignored-hmr/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const WebpackRemoveEmptyScripts = require('../../../src/index.js');
1+
const RemoveEmptyScriptsPlugin = require('../../../src/index.js');
22

33
const webpack = require('webpack');
44
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
@@ -19,7 +19,7 @@ module.exports = {
1919
],
2020
},
2121
plugins: [
22-
new WebpackRemoveEmptyScripts({
22+
new RemoveEmptyScriptsPlugin({
2323
ignore: [
2424
'webpack-hot-middleware',
2525
]

test/cases/css-entry-with-query/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const WebpackRemoveEmptyScripts = require('../../../src/index.js');
1+
const RemoveEmptyScriptsPlugin = require('../../../src/index.js');
22

33
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
44

@@ -13,7 +13,7 @@ module.exports = {
1313
],
1414
},
1515
plugins: [
16-
new WebpackRemoveEmptyScripts(),
16+
new RemoveEmptyScriptsPlugin(),
1717
new MiniCssExtractPlugin({
1818
filename: '[name].css',
1919
}),

0 commit comments

Comments
 (0)