Make WordPress Core

Opened 3 weeks ago

Last modified 2 weeks ago

#61575 new defect (bug)

Node Modules in sub-directories not getting ignored while exporting the theme

Reported by: rajinsharwar's profile rajinsharwar Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch 2nd-opinion
Focuses: Cc:


There is an issue with node_modules not getting ignored while in the sub-directory and adding a new filter for permission capability for the Export button.

To replicate try to run these commands to add the node_modules under any sub-directory in the theme.:

  1. cd ../path/to/wp-content/themes/twentytwentythree/assets
  2. npm install some-package
  3. Export the theme.

You will see that the node_modules folder is present when the theme is exported.

Change History (3)

This ticket was mentioned in PR #6970 on WordPress/wordpress-develop by @rajinsharwar.

3 weeks ago

  • Keywords has-patch added

Fixing issue with node_modules not getting ignored while in sub-directory and adding new filter for permission capability for Export button.

Trac ticket:

#2 @peterwilsoncc
3 weeks ago

It's difficult to know the developer's intent with regard to exporting node_modules.

As NPM packages include both production and development dependencies, it's possible the intent is to include the folder as it contains code required for production websites.

If the theme directory includes NPM or yarn config files, it might be safe to assume that the node_modules folder can be excluded and require it be run upon deploy. If it doesn't then I think we certainly want to retain node_modules.

The complicating factor is when accounting for uploading of themes. If the folder doesn't include node_modules and the site owner has no way of running it then there is a risk of breaking sites.

#3 @rajinsharwar
2 weeks ago

  • Keywords 2nd-opinion added

As of my understanding, currently, even without the patch, we are not checking if the theme has NPM or yearn config files, and then only deleting the node_modules folder if it does.

Not entirely sure, but should we consider adding a filter or something using which the theme author can define if he exclusively wants the node_modules or any other folder in the theme to be included or not @peterwilsoncc?

Note: See TracTickets for help on using tickets.