Skip to content

Commit f4f57f5

Browse files
committed
chore: reduce npm package size
1 parent 84157f8 commit f4f57f5

File tree

65 files changed

+1127
-532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1127
-532
lines changed

.github/workflows/test.yml

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,74 @@ on:
44
push:
55
branches:
66
- master
7+
- next
78
pull_request:
89
branches:
910
- master
11+
- next
1012

1113
jobs:
12-
integration:
14+
build:
15+
name: Build package
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 1
22+
23+
# Rollup requires Node.js >=18
24+
- name: Set up Node.js 18
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 18
28+
29+
- name: Install dependencies
30+
run: npm install
31+
32+
- name: Build package
33+
run: npm run build
34+
35+
- name: Save build artifacts
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: built-package
39+
path: ./dist/ # build output
40+
retention-days: 1 # keep the artifact for 1 day
41+
42+
test:
43+
name: Test LTS
44+
needs: build
1345
strategy:
1446
matrix:
1547
os: [ubuntu-latest]
16-
node-version: [ 14, 16, 18, 20 ]
17-
48+
node-version: [ 18, 20, 22 ]
1849
runs-on: ${{ matrix.os }}
1950
steps:
2051
- name: Checkout repository
21-
uses: actions/checkout@v3
52+
uses: actions/checkout@v4
2253
with:
2354
fetch-depth: 1
2455

2556
- name: Set up Node.js ${{ matrix.node-version }}
26-
uses: actions/setup-node@v3
57+
uses: actions/setup-node@v4
2758
with:
2859
node-version: ${{ matrix.node-version }}
2960

30-
- name: Install dependencies
31-
run: npm i
61+
- name: Download built package
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: built-package
65+
path: ./dist/
66+
67+
- name: Install dependencies (without rebuilding)
68+
run: npm install --ignore-scripts
3269

3370
- name: Run the tests
3471
run: npm run test:coverage
3572

3673
- name: Submit coverage data to codecov
3774
uses: codecov/codecov-action@v3
3875
with:
39-
flags: integration
76+
flags: test
4077
token: ${{ secrets.CODECOV_TOKEN }}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.1.0 (2025-05-25)
2+
3+
- chore: optimize npm package and reduce unpacked size: 31 kB -> 9 kB
4+
- docs: update readme
5+
6+
## 1.0.4 (2023-09-23)
7+
- docs: update readme
8+
19
## 1.0.4 (2023-08-28)
210
- fix: remove needless double new lines in console output when the `verbose` option is enabled
311
- chore: add Community Standards files

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ISC License
22

3-
Copyright (c) 2021-2024, webdiscus
3+
Copyright (c) 2021-2025, webdiscus
44
Copyright (c) 20218-2020, fqborges
55

66
Permission to use, copy, modify, and/or distribute this software for any

README.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
<div align="center">
22
<img width="120" height="120" src="https://cdn.worldvectorlogo.com/logos/logo-javascript.svg">
3-
<a href="https://webpack.js.org/">
4-
<img width="120" height="120" vspace="" hspace="25" src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon-square-big.svg">
5-
</a>
3+
<img width="120" height="120" vspace="" hspace="25" src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon-square-big.svg">
64
<h1><a href="https://github.com/webdiscus/webpack-remove-empty-scripts">webpack-remove-empty-scripts</a></h1>
7-
<div>The Webpack plugin removes empty JavaScript files generated when using styles.</div>
85
</div>
96

10-
---
117
[![npm](https://img.shields.io/npm/v/webpack-remove-empty-scripts?logo=npm&color=brightgreen "npm package")](https://www.npmjs.com/package/webpack-remove-empty-scripts "download npm package")
128
[![node](https://img.shields.io/node/v/webpack-remove-empty-scripts)](https://nodejs.org)
139
[![node](https://img.shields.io/github/package-json/dependency-version/webdiscus/webpack-remove-empty-scripts/peer/webpack)](https://webpack.js.org/)
1410
[![Test](https://github.com/webdiscus/webpack-remove-empty-scripts/actions/workflows/test.yml/badge.svg)](https://github.com/webdiscus/webpack-remove-empty-scripts/actions/workflows/test.yml)
1511
[![codecov](https://codecov.io/gh/webdiscus/webpack-remove-empty-scripts/branch/master/graph/badge.svg)](https://codecov.io/gh/webdiscus/webpack-remove-empty-scripts)
1612
[![node](https://img.shields.io/npm/dm/webpack-remove-empty-scripts)](https://www.npmjs.com/package/webpack-remove-empty-scripts)
1713

18-
## The problem this plugin solves
14+
A Webpack plugin to remove empty JavaScript files generated when using style only entries.
15+
16+
## Problem this plugin solves
17+
18+
By default, Webpack creates a JavaScript file for every entry specified in the `entry` option - even when the entry is a style file (like SCSS or CSS).
1919

20-
Webpack generates a JS file for each resource defined in the entry option.
20+
Example:
2121

22-
For example, you have a style file in the `entry` option:
2322
```js
2423
module.exports = {
2524
entry: {
@@ -28,28 +27,24 @@ module.exports = {
2827
}
2928
```
3029

31-
The following files are generated in the output directory:
30+
Output:
3231

3332
```
3433
dist/styles.css
35-
dist/styles.js // <= unexpected empty JS file
34+
dist/styles.js // <= unwanted empty JS file
3635
```
3736

38-
This plugin removes generated empty JS files.
39-
40-
> **Warning**
41-
>
42-
> This plugin is the `Crutch` 🩼 for the [mini-css-extract-plugin issue](https://github.com/webpack-contrib/mini-css-extract-plugin/issues/151).\
43-
> The `mini-css-extract-plugin` extract CSS, but not eliminate a generated empty JS file.
44-
>
37+
When using `mini-css-extract-plugin`, CSS is correctly extracted into a separate file, but Webpack still emits an empty JavaScript file for each style-only entry - the [known issue](https://github.com/webpack-contrib/mini-css-extract-plugin/issues/151).
4538

39+
This plugin detects and removes those redundant `.js` files automatically, keeping your output clean.
4640

47-
> **Note**
48-
>
49-
> This plugin is compatible with `Webpack 5`. For `Webpack 4` use [webpack-fix-style-only-entries](https://github.com/fqborges/webpack-fix-style-only-entries).
41+
> [!NOTE]
42+
>
43+
> This plugin is compatible with `Webpack 5`.
44+
> For `Webpack 4` use [webpack-fix-style-only-entries](https://github.com/fqborges/webpack-fix-style-only-entries).
5045
5146
## Install
52-
```console
47+
```bash
5348
npm install webpack-remove-empty-scripts --save-dev
5449
```
5550

README.npm.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<div align="center">
2+
<img width="120" height="120" src="https://cdn.worldvectorlogo.com/logos/logo-javascript.svg">
3+
<img width="120" height="120" vspace="" hspace="25" src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon-square-big.svg">
4+
<h1><a href="https://github.com/webdiscus/webpack-remove-empty-scripts">webpack-remove-empty-scripts</a></h1>
5+
</div>
6+
7+
A Webpack plugin to remove empty JavaScript files generated when using style only entries.
8+
9+
## Problem this plugin solves
10+
11+
By default, Webpack creates a JavaScript file for every entry specified in the `entry` option - even when the entry is a style file (like SCSS or CSS).
12+
13+
Example:
14+
15+
```js
16+
module.exports = {
17+
entry: {
18+
styles: './styles.scss',
19+
},
20+
}
21+
```
22+
23+
Output:
24+
25+
```
26+
dist/styles.css
27+
dist/styles.js // <= unwanted empty JS file
28+
```
29+
30+
When using `mini-css-extract-plugin`, CSS is correctly extracted into a separate file, but Webpack still emits an empty JavaScript file for each style-only entry - the [known issue](https://github.com/webpack-contrib/mini-css-extract-plugin/issues/151).
31+
32+
This plugin detects and removes those redundant `.js` files automatically, keeping your output clean.
33+
34+
> **Note**
35+
>
36+
> This plugin is compatible with `Webpack 5`.
37+
> For `Webpack 4` use [webpack-fix-style-only-entries](https://github.com/fqborges/webpack-fix-style-only-entries).
38+
39+
## Install
40+
```bash
41+
npm install webpack-remove-empty-scripts --save-dev
42+
```
43+
44+
See the full [documentation](https://github.com/webdiscus/webpack-remove-empty-scripts) on GitHub.

package.json

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-remove-empty-scripts",
3-
"version": "1.0.4",
3+
"version": "1.1.0",
44
"description": "Webpack plugin removes empty JavaScript files generated when using styles.",
55
"keywords": [
66
"webpack",
@@ -14,8 +14,7 @@
1414
"sass",
1515
"css",
1616
"js",
17-
"javascript",
18-
"mini-css-extract-plugin"
17+
"javascript"
1918
],
2019
"license": "ISC",
2120
"author": "webdiscus (https://github.com/webdiscus)",
@@ -41,14 +40,15 @@
4140
"main": "src/index.js",
4241
"scripts": {
4342
"install:yarn": "yarn install --ignore-engines",
43+
"postinstall": "npm run build && npm i webpack-remove-empty-scripts -D",
44+
"build": "rollup -c",
4445
"test": "jest --detectOpenHandles --config ./test/jest.config.js",
4546
"test:coverage": "jest --detectOpenHandles --collectCoverage --config ./test/jest.config.js",
46-
"publish:public": "npm publish --access public",
47-
"publish:beta": "npm publish --tag beta"
47+
"publish:public": "(npm run build) && npm publish ./dist --access public",
48+
"publish:beta": "(npm run build) && npm publish ./dist --tag beta"
4849
},
4950
"files": [
5051
"src",
51-
"CHANGELOG.md",
5252
"README.md",
5353
"LICENSE"
5454
],
@@ -59,24 +59,34 @@
5959
"webpack": ">=5.32.0"
6060
},
6161
"dependencies": {
62-
"ansis": "1.5.2"
62+
"ansis": "4.0.0-node10"
6363
},
6464
"devDependencies": {
65-
"@babel/core": "^7.23.7",
66-
"@babel/preset-env": "^7.23.8",
65+
"@babel/core": "^7.27.1",
66+
"@babel/preset-env": "^7.27.2",
67+
"@rollup/plugin-commonjs": "^28.0.3",
68+
"@rollup/plugin-node-resolve": "^16.0.1",
69+
"@rollup/plugin-terser": "^0.4.4",
6770
"@test-fixtures/lorem": "0.0.2",
68-
"@types/jest": "^29.5.11",
69-
"@wordpress/scripts": "^27.0.0",
70-
"@wordpress/dependency-extraction-webpack-plugin": "^5.0.0",
71-
"css-loader": "^6.9.0",
72-
"html-bundler-webpack-plugin": "^3.4.10",
73-
"html-loader": "^5.0.0",
71+
"@types/jest": "^29.5.14",
72+
"@wordpress/scripts": "^30.17.0",
73+
"@wordpress/dependency-extraction-webpack-plugin": "^6.24.0",
74+
"css-loader": "^7.1.2",
75+
"html-loader": "^5.1.0",
7476
"jest": "^29.7.0",
75-
"mini-css-extract-plugin": "^2.7.7",
76-
"terser-webpack-plugin": "^5.3.10",
77-
"webpack": "^5.89.0",
78-
"webpack-hot-middleware": "^2.26.0",
79-
"webpack-manifest-plugin": "^5.0.0",
80-
"webpack-merge": "^5.10.0"
77+
"mini-css-extract-plugin": "^2.9.2",
78+
"rollup": "^4.41.1",
79+
"rollup-plugin-copy": "^3.5.0",
80+
"terser-webpack-plugin": "^5.3.14",
81+
"webpack": "^5.99.9",
82+
"webpack-hot-middleware": "^2.26.1",
83+
"webpack-manifest-plugin": "^5.0.1",
84+
"webpack-merge": "^6.0.1",
85+
"webpack-remove-empty-scripts": "file:dist"
86+
},
87+
"overrides": {
88+
"rollup-plugin-copy": {
89+
"globby": "^11.0.0"
90+
}
8191
}
8292
}

package.npm.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "webpack-remove-empty-scripts",
3+
"version": "1.1.0",
4+
"description": "Webpack plugin removes empty JavaScript files generated when using styles.",
5+
"keywords": [
6+
"webpack",
7+
"plugin",
8+
"remove",
9+
"empty",
10+
"script",
11+
"entry",
12+
"style",
13+
"scss",
14+
"sass",
15+
"css",
16+
"js",
17+
"javascript"
18+
],
19+
"license": "ISC",
20+
"author": "webdiscus",
21+
"funding": {
22+
"type": "patreon",
23+
"url": "https://patreon.com/biodiscus"
24+
},
25+
"repository": "webdiscus/webpack-remove-empty-scripts",
26+
"main": "src/index.js",
27+
"engines": {
28+
"node": ">=12.14"
29+
},
30+
"peerDependencies": {
31+
"webpack": ">=5.32.0"
32+
},
33+
"dependencies": {
34+
"ansis": "4.0.0-node10"
35+
}
36+
}

0 commit comments

Comments
 (0)