diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..2eca299 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,11 @@ +coverage: + status: + project: + default: + target: 90% + patch: + default: + target: 90% + +ignore: + - test/.* diff --git a/.github/workflows/codecov.yml b/.github/workflows/test.yml similarity index 100% rename from .github/workflows/codecov.yml rename to .github/workflows/test.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index fef2526..de7fc10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,70 +1,76 @@ -## 0.7.2 (Dec 13, 2021) The last stable version -- add new option `enable` to enable / disable the plugin, e.g. by development -- add support of `RegExp` for option `extensions` +## 0.7.3 (Jan 30, 2022) The last stable version +- added color verbose output via ANSI color library - ansis +- added the test case for styles imported from javascript + +## 0.7.2 (Dec 13, 2021) +- added new option `enable` to enable / disable the plugin, e.g. by development +- added supports of `RegExp` for option `extensions` - remove deprecated option `silent`, use `verbose` to show process information (no braking change) -- add GitHub workflow + codecov -- color verbose output +- added GitHub workflow + codecov - update packages - update readme ## 0.7.1 (Jan 14, 2021) ### Bugfixes -- The issue infinite recursion by collect of resources from dependency modules by usage in react app some big components with many thousands dependencies. +- fix the issue infinite recursion by collect of resources from dependency modules by usage in react app some big components with many thousands dependencies ## 0.7.0 (Dec 21, 2020) ### Breaking change -- 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`. +- 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`. ### Bugfixes -- The issue `Maximum call stack size exceeded` was general fixed in all cases, for example, by usage the webpack setting `optimization.concatenateModules: true` and: +- fix issue `Maximum call stack size exceeded` in all cases, for example, by usage the webpack setting `optimization.concatenateModules: true` and: - import react - import redux - webpack setting `externals.jquery: 'jQuery'` or other external libs - The issue if first in webpack entries are a styles and then a scripts. ## 0.6.4 (Dec 19, 2020) -- Bugfix the error: `Maximum call stack size exceeded` with webpack setting `optimization.concatenateModules: true`and usage in script imports from `react` and `redux`. -- Add test case for single style without a scripts in webpack config. -- Add silent mode in tests to suppress output log info in the console. -- 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. -- Update npm packages. +- fix the error: `Maximum call stack size exceeded` with webpack setting `optimization.concatenateModules: true`and usage in script imports from `react` and `redux` +- added the test case for single style without a scripts in webpack config +- added silent mode in tests to suppress output log info in the console +- improve the option `ignore`: + - it can be the array of string or RegExp + - added default value of `ignore` as `['/node_modules/']` to ignore resources from `node_modules` path +- update npm packages. ## 0.6.3 (Oct 25, 2020) -Fix BREAKING CHANGE in Webpack 5: No more changes should happen to `Compilation.assets`. Update code accord new API. +- fix BREAKING CHANGE in Webpack 5: no more changes should happen to `Compilation.assets` +- update code accord new API ## 0.6.2 (Oct 24, 2020) Update npm packages. ## 0.6.1 (Oct 20, 2020) -The fork of original `https://github.com/fqborges/webpack-fix-style-only-entries` (ver. 0.6.0) for support only Webpack 5 and above. +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. The Webpack 4 is no longer supported. -The changes from original version 0.6.0: +### The changes from original version 0.6.0: -- Added the feature: considers the use hash after the .js and .mjs extension in file format like `.js?[hash]` or `.mjs?[hash]`. -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 +- feature: considers the use hash after the .js and .mjs extension in file format like `.js?[hash]` or `.mjs?[hash]`. +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) - In Webpack 5 fixed deprecation messages: - DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE - DEP_WEBPACK_CHUNK_ENTRY_MODULE - DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET - DEP_WEBPACK_MODULE_INDEX -- Update all packages for Webpack 5. -- Fix integration test script for using with Webpack 5. -- 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`. -- Fix module structure in README.md. +- update all packages for Webpack 5. +- fix integration test script for using with Webpack 5. +- 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`. +- fix module structure in README.md. ## 0.6.0 (Oct 13, 2020) 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. - 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)) ## 0.5.2 (Oct 07, 2020) - - Webpack 5 support using ModuleGraph API (PR [#38](https://github.com/fqborges/webpack-fix-style-only-entries/pull/38)) + - supports Webpack 5 using ModuleGraph API (PR [#38](https://github.com/fqborges/webpack-fix-style-only-entries/pull/38)) - npm audit fix: ([ea9dd7](https://github.com/fqborges/webpack-fix-style-only-entries/commit/ea9dd7bd7ade5b16623064a4850de39545e1e18e)) ## 0.5.1 (Jun 13, 2020) - - Fix Maximum call stack size exceeded (PR [#34](https://github.com/fqborges/webpack-fix-style-only-entries/pull/34)) - - Added CHANGELOG ([3e3767](https://github.com/fqborges/webpack-fix-style-only-entries/commit/3e3767d8998a53d807b5d5b10643d05b800aa79a)) + - fix Maximum call stack size exceeded (PR [#34](https://github.com/fqborges/webpack-fix-style-only-entries/pull/34)) + - added CHANGELOG ([3e3767](https://github.com/fqborges/webpack-fix-style-only-entries/commit/3e3767d8998a53d807b5d5b10643d05b800aa79a)) ## 0.5.0 (May 18, 2020) - 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)) diff --git a/README.md b/README.md index 189e59d..0898207 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![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) +[![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) [![node](https://img.shields.io/node/v/webpack-remove-empty-scripts)](https://nodejs.org) [![node](https://img.shields.io/github/package-json/dependency-version/webdiscus/webpack-remove-empty-scripts/peer/webpack)](https://webpack.js.org/) [![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: > Please test your project before using it in production.\ > If you have a problem with the new version, please create a [new issue](https://github.com/webdiscus/webpack-remove-empty-scripts/issues). -> :warning: The last stable release is `0.7.2` in the branch [`stable`](https://github.com/webdiscus/webpack-remove-empty-scripts/tree/stable). +> :warning: The last stable release is `0.7.3` in the branch [`stable`](https://github.com/webdiscus/webpack-remove-empty-scripts/tree/stable). ## Propose 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({ ## Also See - more examples of usages see in [test cases](https://github.com/webdiscus/webpack-remove-empty-scripts/tree/master/test/cases) -- [`pug-plugin`][pug-plugin] -- [`pug-loader`][pug-loader] +- [ansis][ansis] - ANSI color styling of text in terminal +- [pug-plugin][pug-plugin] +- [pug-loader][pug-loader] ## License [ISC](https://github.com/webdiscus/webpack-remove-empty-scripts/blob/master/LICENSE) +[ansis]: https://github.com/webdiscus/ansis [pug-plugin]: https://github.com/webdiscus/pug-plugin [pug-loader]: https://github.com/webdiscus/pug-loader diff --git a/package.json b/package.json index 703eef3..0e818db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack-remove-empty-scripts", - "version": "0.7.2", + "version": "0.7.3", "description": "Webpack 5 plugin to remove empty scripts generated by usage only styles in webpack entry.", "keywords": [ "webpack", @@ -13,8 +13,8 @@ "sass", "css", "js", - "mini-css-extract-plugin", - "webpack-fix-style-only-entries" + "entry", + "css-extract" ], "license": "ISC", "author": "webdiscus (https://github.com/webdiscus)", @@ -63,20 +63,22 @@ "peerDependencies": { "webpack": ">=5.32.0" }, - "dependencies": {}, + "dependencies": { + "ansis": "^1.3.4" + }, "devDependencies": { - "@babel/core": "^7.16.0", - "@babel/preset-env": "^7.16.4", - "@types/jest": "^27.0.3", + "@babel/core": "^7.16.12", + "@babel/preset-env": "^7.16.11", + "@types/jest": "^27.4.0", "css-loader": "^6.5.1", "fs": "^0.0.1-security", - "html-loader": "^3.0.1", - "jest": "^27.4.4", - "mini-css-extract-plugin": "^2.4.5", + "html-loader": "^3.1.0", + "jest": "^27.4.7", + "mini-css-extract-plugin": "^2.5.3", "moment": "^2.29.1", "rimraf": "^3.0.2", - "terser-webpack-plugin": "^5.2.5", - "webpack": "^5.65.0", + "terser-webpack-plugin": "^5.3.0", + "webpack": "^5.67.0", "webpack-hot-middleware": "^2.25.1", "webpack-merge": "^5.8.0" } diff --git a/src/color-string.js b/src/color-string.js deleted file mode 100644 index be97ae4..0000000 --- a/src/color-string.js +++ /dev/null @@ -1,61 +0,0 @@ -const colors = { - reset: '0', - bold: '1', - bright: '1', - dim: '2', - underscore: '4', - blink: '5', - reverse: '7', - hidden: '8', - - black: '30', - red: '31', - green: '32', - yellow: '33', - blue: '34', - magenta: '35', - cyan: '36', - white: '37', - - bgBlack: '40', - bgRed: '41', - bgGreen: '42', - bgYellow: '43', - bgBlue: '44', - bgMagenta: '45', - bgCyan: '46', - bgWhite: '47', -}; - -/** - * @param {string} str The text string. - * @param {string} code The code of color. - * @param {string} bgCode The code of background color. - * @return {string} - */ -const strColor = (str, code, bgCode = '') => { - if (!code) code = colors.white; - - return (bgCode ? `\x1b[${bgCode};${code}m` : `\x1b[${code}m`) + str + `\x1b[${colors.reset}m`; -}; - -module.exports = { - black: (str) => strColor(str, colors.black), - red: (str) => strColor(str, colors.red), - green: (str) => strColor(str, colors.green), - yellow: (str) => strColor(str, colors.yellow), - blue: (str) => strColor(str, colors.blue), - magenta: (str) => strColor(str, colors.magenta), - cyan: (str) => strColor(str, colors.cyan), - white: (str) => strColor(str, colors.white), - bgBlack: (str, color) => strColor(str, color, colors.bgBlack), - bgRed: (str, color) => strColor(str, color, colors.bgRed), - bgGreen: (str, color) => strColor(str, color, colors.bgGreen), - bgYellow: (str, color) => strColor(str, color, colors.bgYellow), - bgBlue: (str, color) => strColor(str, color, colors.bgBlue), - bgMagenta: (str, color) => strColor(str, color, colors.bgMagenta), - bgCyan: (str, color) => strColor(str, color, colors.bgCyan), - bgWhite: (str, color) => strColor(str, color, colors.bgWhite), -}; - -module.exports.colors = colors; diff --git a/src/index.js b/src/index.js index 135aea5..79e7e1f 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ */ const path = require('path'); -const colstr = require('./color-string'); +const ansis = require('ansis'); const plugin = 'remove-empty-scripts'; const defaultOptions = { @@ -55,7 +55,7 @@ class WebpackRemoveEmptyScriptsPlugin { for (const module of chunkGraph.getChunkEntryModulesIterable(chunk)) { if (!compilation.modules.has(module)) { throw new Error( - `${plugin} checkConstraints: entry module in chunk but not in compilation ${chunk.debugId} ${module.debugId}` + `\n${ansis.black.bgRed(`[${plugin}]`)} entry module in chunk but not in compilation ${chunk.debugId} ${module.debugId}` ); } @@ -74,7 +74,7 @@ class WebpackRemoveEmptyScriptsPlugin { if (this.verbose) { const outputFile = path.join(outputPath, filename); console.log( - ` ${colstr.bgYellow(` ${plugin} `, colstr.colors.black)} remove ${colstr.cyan(outputFile)}`, + `${ansis.black.bgYellow(`[${plugin}]`)} remove ${ansis.cyan(outputFile)}`, ); } diff --git a/test/cases/css-entry-only/webpack.config.js b/test/cases/css-entry-only/webpack.config.js index 557353c..e2b74b5 100644 --- a/test/cases/css-entry-only/webpack.config.js +++ b/test/cases/css-entry-only/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -16,7 +16,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ enabled: true, verbose: true, }), diff --git a/test/cases/css-entry-with-ignored-hmr/webpack.config.js b/test/cases/css-entry-with-ignored-hmr/webpack.config.js index 49a835b..6ecf0fe 100644 --- a/test/cases/css-entry-with-ignored-hmr/webpack.config.js +++ b/test/cases/css-entry-with-ignored-hmr/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const webpack = require('webpack'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -19,7 +19,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ ignore: [ 'webpack-hot-middleware', ] diff --git a/test/cases/css-entry-with-query/webpack.config.js b/test/cases/css-entry-with-query/webpack.config.js index de538c0..66f1e08 100644 --- a/test/cases/css-entry-with-query/webpack.config.js +++ b/test/cases/css-entry-with-query/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -13,7 +13,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/css-import/expected.json b/test/cases/css-import/expected.json new file mode 100644 index 0000000..ae08271 --- /dev/null +++ b/test/cases/css-import/expected.json @@ -0,0 +1,5 @@ +[ + "main.css", + "main.js", + "style.css" +] \ No newline at end of file diff --git a/test/cases/css-import/main.js b/test/cases/css-import/main.js new file mode 100644 index 0000000..2837eda --- /dev/null +++ b/test/cases/css-import/main.js @@ -0,0 +1,2 @@ +import './vendor.css'; +console.log('main'); \ No newline at end of file diff --git a/test/cases/css-import/style.css b/test/cases/css-import/style.css new file mode 100644 index 0000000..d79138d --- /dev/null +++ b/test/cases/css-import/style.css @@ -0,0 +1,5 @@ +html, +body { + width: 100%; + height: 100%; +} diff --git a/test/cases/css-import/vendor.css b/test/cases/css-import/vendor.css new file mode 100644 index 0000000..3070e1a --- /dev/null +++ b/test/cases/css-import/vendor.css @@ -0,0 +1,3 @@ +.vendor { + color: red; +} \ No newline at end of file diff --git a/test/cases/css-import/webpack.config.js b/test/cases/css-import/webpack.config.js new file mode 100644 index 0000000..b8e0ea5 --- /dev/null +++ b/test/cases/css-import/webpack.config.js @@ -0,0 +1,27 @@ +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); + +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); + +module.exports = { + entry: { + main: ['./style.css', './main.js' ], + style: ['./style.css'], + }, + module: { + rules: [ + { + test: /\.css$/, + use: [MiniCssExtractPlugin.loader, 'css-loader'], + }, + ], + }, + plugins: [ + new RemoveEmptyScriptsPlugin({ + enabled: true, + verbose: true, + }), + new MiniCssExtractPlugin({ + filename: '[name].css', + }), + ], +}; \ No newline at end of file diff --git a/test/cases/multi-configuration/webpack.config.js b/test/cases/multi-configuration/webpack.config.js index 7736579..2d28460 100644 --- a/test/cases/multi-configuration/webpack.config.js +++ b/test/cases/multi-configuration/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -12,7 +12,7 @@ const baseConfig = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/multi-js-entry-css-entry-extensions-do-not-match/webpack.config.js b/test/cases/multi-js-entry-css-entry-extensions-do-not-match/webpack.config.js index baeefef..3adebb5 100644 --- a/test/cases/multi-js-entry-css-entry-extensions-do-not-match/webpack.config.js +++ b/test/cases/multi-js-entry-css-entry-extensions-do-not-match/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -13,7 +13,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ //extensions: ['foo', 'bar'], extensions: /\.(foo|bar)$/, }), diff --git a/test/cases/multi-js-entry-css-entry-mjs-output-css-output/webpack.config.js b/test/cases/multi-js-entry-css-entry-mjs-output-css-output/webpack.config.js index 229f852..a840a90 100644 --- a/test/cases/multi-js-entry-css-entry-mjs-output-css-output/webpack.config.js +++ b/test/cases/multi-js-entry-css-entry-mjs-output-css-output/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -16,7 +16,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/multi-js-entry-css-entry/webpack.config.js b/test/cases/multi-js-entry-css-entry/webpack.config.js index 9b01ad8..6aa2ae2 100644 --- a/test/cases/multi-js-entry-css-entry/webpack.config.js +++ b/test/cases/multi-js-entry-css-entry/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -13,7 +13,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/multi-mjs-entry-css-entry/webpack.config.js b/test/cases/multi-mjs-entry-css-entry/webpack.config.js index 3f011d4..d76c86d 100644 --- a/test/cases/multi-mjs-entry-css-entry/webpack.config.js +++ b/test/cases/multi-mjs-entry-css-entry/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -16,7 +16,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/multi-page+styles/webpack.config.js b/test/cases/multi-page+styles/webpack.config.js index 293120e..40bf4ec 100644 --- a/test/cases/multi-page+styles/webpack.config.js +++ b/test/cases/multi-page+styles/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -37,7 +37,7 @@ module.exports = { }, }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ //verbose: true }), new MiniCssExtractPlugin({ diff --git a/test/cases/option-extension-array/webpack.config.js b/test/cases/option-extension-array/webpack.config.js index a9a8b28..a06f198 100644 --- a/test/cases/option-extension-array/webpack.config.js +++ b/test/cases/option-extension-array/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -13,7 +13,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ extensions: ['foo', 'bar'], //extensions: /\.(foo|bar)$/, }), diff --git a/test/cases/option-extension-regexp/webpack.config.js b/test/cases/option-extension-regexp/webpack.config.js index baeefef..3adebb5 100644 --- a/test/cases/option-extension-regexp/webpack.config.js +++ b/test/cases/option-extension-regexp/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -13,7 +13,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ //extensions: ['foo', 'bar'], extensions: /\.(foo|bar)$/, }), diff --git a/test/cases/option-ignore-array/webpack.config.js b/test/cases/option-ignore-array/webpack.config.js index 5dd39fc..359a217 100644 --- a/test/cases/option-ignore-array/webpack.config.js +++ b/test/cases/option-ignore-array/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const webpack = require('webpack'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -19,7 +19,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ ignore: [ /.+-hot-middleware\//, ] diff --git a/test/cases/option-ignore-string/webpack.config.js b/test/cases/option-ignore-string/webpack.config.js index 5ce5f2f..d8efd7c 100644 --- a/test/cases/option-ignore-string/webpack.config.js +++ b/test/cases/option-ignore-string/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const webpack = require('webpack'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -19,7 +19,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ + new RemoveEmptyScriptsPlugin({ ignore: 'webpack-hot-middleware' }), new MiniCssExtractPlugin({ diff --git a/test/cases/single-js+css-entry-mjs+css-output/webpack.config.js b/test/cases/single-js+css-entry-mjs+css-output/webpack.config.js index 61c6f7c..7d71868 100644 --- a/test/cases/single-js+css-entry-mjs+css-output/webpack.config.js +++ b/test/cases/single-js+css-entry-mjs+css-output/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -16,7 +16,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/single-js+css-entry/webpack.config.js b/test/cases/single-js+css-entry/webpack.config.js index 4163c3e..11446df 100644 --- a/test/cases/single-js+css-entry/webpack.config.js +++ b/test/cases/single-js+css-entry/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -14,7 +14,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts({ verbose: true }), + new RemoveEmptyScriptsPlugin({ verbose: true }), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/single-js-entry-without-ext/webpack.config.js b/test/cases/single-js-entry-without-ext/webpack.config.js index 80503f8..0c910d6 100644 --- a/test/cases/single-js-entry-without-ext/webpack.config.js +++ b/test/cases/single-js-entry-without-ext/webpack.config.js @@ -1,6 +1,6 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); module.exports = { entry: './index', - plugins: [new WebpackRemoveEmptyScripts()], + plugins: [new RemoveEmptyScriptsPlugin()], }; \ No newline at end of file diff --git a/test/cases/single-mjs+css-entry/webpack.config.js b/test/cases/single-mjs+css-entry/webpack.config.js index 03cc7ac..fae9857 100644 --- a/test/cases/single-mjs+css-entry/webpack.config.js +++ b/test/cases/single-mjs+css-entry/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -16,7 +16,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/single-mjs-entry/webpack.config.js b/test/cases/single-mjs-entry/webpack.config.js index a366747..d808bc6 100644 --- a/test/cases/single-mjs-entry/webpack.config.js +++ b/test/cases/single-mjs-entry/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); module.exports = { entry: './index.mjs', @@ -6,6 +6,6 @@ module.exports = { filename: '[name].mjs', }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), ], }; \ No newline at end of file diff --git a/test/cases/vendor+multi-js-entry-css-entry/webpack.config.js b/test/cases/vendor+multi-js-entry-css-entry/webpack.config.js index 2b4ec58..2f09de5 100644 --- a/test/cases/vendor+multi-js-entry-css-entry/webpack.config.js +++ b/test/cases/vendor+multi-js-entry-css-entry/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const TerserPlugin = require('terser-webpack-plugin'); @@ -34,7 +34,7 @@ module.exports = { }, }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/cases/webpack-concatenate-modules/webpack.config.js b/test/cases/webpack-concatenate-modules/webpack.config.js index e6b3f75..9f239da 100644 --- a/test/cases/webpack-concatenate-modules/webpack.config.js +++ b/test/cases/webpack-concatenate-modules/webpack.config.js @@ -1,4 +1,4 @@ -const WebpackRemoveEmptyScripts = require('../../../src/index.js'); +const RemoveEmptyScriptsPlugin = require('../../../src/index.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -13,7 +13,7 @@ module.exports = { ], }, plugins: [ - new WebpackRemoveEmptyScripts(), + new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin({ filename: '[name].css', }), diff --git a/test/index.integration.test.js b/test/index.integration.test.js index f974606..f843d39 100644 --- a/test/index.integration.test.js +++ b/test/index.integration.test.js @@ -11,6 +11,7 @@ const modes = ['development', 'production']; // if not empty, then test only this cases const testOnly = [ + //'css-import', //'option-extension-array', //'option-extension-regexp', //'option-ignore-array', @@ -48,6 +49,7 @@ describe('Webpack Integration Tests', () => { if (testOnly.length > 0 && testOnly.indexOf(testCase) < 0) return; modes.forEach(mode => { + jest.setTimeout(10000); test(testCase + ' [' + mode + ']', done => { const testDirectory = path.join(__dirname, 'cases', testCase); const outputDirectory = path.join(__dirname, 'output', testCase, mode); diff --git a/test/index.unit.test.js b/test/index.unit.test.js deleted file mode 100644 index 17e1256..0000000 --- a/test/index.unit.test.js +++ /dev/null @@ -1,33 +0,0 @@ -import colstr from '../src/color-string'; - -beforeAll(() => { -}); - -beforeEach(() => { - jest.setTimeout(2000); -}); - -describe('color string tests', () => { - const colorMethod = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']; - const bgColorMethod = ['bgBlack', 'bgRed', 'bgGreen', 'bgYellow', 'bgBlue', 'bgMagenta', 'bgCyan', 'bgWhite']; - - colorMethod.forEach((color) => { - test(`colstr.${color}`, (done) => { - const str = 'ok'; - const received = colstr[color](str); - const expected = `\x1b[${colstr.colors[color]}m` + str + `\x1b[${colstr.colors.reset}m`; - expect(received).toEqual(expected); - done(); - }); - }); - - bgColorMethod.forEach((color) => { - test(`colstr.${color}`, (done) => { - const str = 'ok'; - const received = colstr[color](str); - const expected = `\x1b[${colstr.colors[color]};${colstr.colors.white}m` + str + `\x1b[${colstr.colors.reset}m`; - expect(received).toEqual(expected); - done(); - }); - }); -}); \ No newline at end of file