Skip to content

feat: publish only core files to npm package #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

MikeMcC399
Copy link
Collaborator

Situation

The npm package eslint-plugin-cypress published to the npm registry includes files that are not necessary to run the plugin. This bloats the package making it twice the size it needs to be.

The current package.json contains no files options. When this option is omitted, it defaults to ["*"], which means it includes all files from the repo.

Change

Add a files option to package.json.

For linting add the directory:

For links in the README.md, add

The following files are automatically included:

Other files, that are used to set up the repo for development, in CI, for internal testing, and are not needed to run the plugin as a package, are not published with the package to the npm registry.

Impact

The reduction for each of the following metrics related to the published npm package eslint-plugin-cypress is approximately 65%:

Metric Before After
# files 84 30
package size 37.2 kB 13.0 kB
unpacked size 157.7 kB 55.2 kB

Verification

Execute the following:

git clean -xfd
npm ci
npm pack

and inspect the list of files packed into the npm package. There should be 30 files in the package.

Linting

mv eslint-plugin-cypress-0.0.0-development.tgz test-project
cd test-project
npm install eslint@latest eslint-plugin-cypress-0.0.0-development.tgz -D
npx eslint
npx eslint --config eslint-configs/eslint.default.mjs
npx eslint --config eslint-configs/eslint.default-deprecated.mjs
npx eslint --config eslint-configs/eslint.globals.mjs
npx eslint --config eslint-configs/eslint.recommended.mjs

No linting or other errors should be reported.

Markdown links

npm install markdown-link-check -g
markdown-link-check node_modules/eslint-plugin-cypress/README.md

No link errors should be reported.

Clean up

Clean up temporary files:

cd ..
git restore .
git clean -xfd
git status

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 force-pushed the add/package-files-definition branch from 05d7727 to 71f31bd Compare June 3, 2025 06:24
@MikeMcC399 MikeMcC399 marked this pull request as ready for review June 3, 2025 06:25
@jennifer-shehane jennifer-shehane merged commit e622a58 into cypress-io:master Jun 3, 2025
10 checks passed
@jennifer-shehane
Copy link
Member

🎉 This PR is included in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@MikeMcC399 MikeMcC399 deleted the add/package-files-definition branch June 3, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants