Skip to content
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

NPM archive related scripts include node_modules and vendor files in zip. #97

Open
1 task done
peterwilsoncc opened this issue Jan 4, 2023 · 4 comments · May be fixed by #143
Open
1 task done

NPM archive related scripts include node_modules and vendor files in zip. #97

peterwilsoncc opened this issue Jan 4, 2023 · 4 comments · May be fixed by #143
Assignees
Labels
help wanted Extra attention is needed type:bug Something isn't working.
Milestone

Comments

@peterwilsoncc
Copy link
Contributor

Describe the bug

When building an archive using the NPM archive and postarchive scripts, the node_modules and vendor folders are included in the zip file.

In local testing, this created a 69.6 MB zip file.

Steps to Reproduce

  1. Check out develop branch.
  2. Run npm i; composer i; npm run build;
  3. Run npm run archive -- observe the node and vendor folders are included in the zip
  4. Run npm run postarchive
  5. Run cd safe-svg; ls
  6. Observe the unzipped files also include the node_modules and vendor folders

Screenshots, screen recording, code snippet

No response

Environment information

  • Device: macbook pro 2020
  • OS: macOS 12.6.2

WordPress information

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct
@peterwilsoncc peterwilsoncc added the type:bug Something isn't working. label Jan 4, 2023
@jeffpaul
Copy link
Member

@peterwilsoncc any recommended resolution here?

@jeffpaul jeffpaul added the help wanted Extra attention is needed label Mar 20, 2023
@peterwilsoncc
Copy link
Contributor Author

peterwilsoncc commented Mar 21, 2023

It looks like the following needs to be added to the composer config. The catch is that it isn't possible to included the vendor directory as we have a mix of dev and production dependencies. If the archive function is run while the dev dependencies are installed, the file will still be quite large.

	"archive": {
		"exclude": [
			"/.distignore",
			"/.github",
			"/.gitignore",
			"/.wordpress-org",
			"/.wp-env.json",
			"/.wp-env.override.json",
			"/CHANGELOG.md",
			"/CODE_OF_CONDUCT.md",
			"/composer.json",
			"/composer.lock",
			"/CONTRIBUTING.md",
			"/CREDITS.md",
			"/package-lock.json",
			"/package.json",
			"/phpcs.xml",
			"/phpunit.xml.dist",
			"/README.md",
			"/webpack.config.js",
			"/node_modules",
			"/tests"
		]

@jeffpaul jeffpaul added this to the Future Release milestone Mar 21, 2023
@szepeviktor
Copy link
Contributor

The same error if installed as a Composer package (GitHub ZIP contains development files).

We should use gitattributes/export-ignore as composer archive respects that.

@szepeviktor szepeviktor linked a pull request Aug 13, 2023 that will close this issue
@szepeviktor
Copy link
Contributor

szepeviktor commented Aug 13, 2023

We should use gitattributes/export-ignore

Oh no! This solves only the git index part of the problem.
composer archive works on the filesystem and adds everything to the zip file.

@jeffpaul jeffpaul modified the milestones: Future Release, 2.2.0 Aug 14, 2023
@dkotter dkotter modified the milestones: 2.2.0, 2.2.1 Aug 17, 2023
@dkotter dkotter modified the milestones: 2.2.1, 2.3.0 Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type:bug Something isn't working.
Projects
Status: Code Review
Development

Successfully merging a pull request may close this issue.

4 participants