Opened 5 months ago
Last modified 2 months ago
#61575 new defect (bug)
Node Modules in sub-directories not getting ignored while exporting the theme
Reported by: | rajinsharwar | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
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.:
- cd ../path/to/wp-content/themes/twentytwentythree/assets
- npm install some-package
- Export the theme.
You will see that the node_modules folder is present when the theme is exported.
Change History (5)
This ticket was mentioned in PR #6970 on WordPress/wordpress-develop by @rajinsharwar.
5 months ago
#1
- Keywords has-patch added
#2
@
5 months 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
@
5 months 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?
#4
@
2 months ago
@peterwilsoncc Do you have any example of a theme that embeds node_modules folder important for the theme to run?
From my knowledge, we usually have a dist folder that is built and necessary for the export, can't find a reason why a node_modules folder should be included.
#5
@
2 months ago
@Mista-Flo Unfortunately, it's not really that simple. Many of the sites built with WordPress are custom themes built by agencies. While it's known that no bundled themes include files within node_modules
, it's not possible to make the assumption about custom builds or all the themes in the plugin repository.
Fixing issue with node_modules not getting ignored while in sub-directory and adding new filter for permission capability for Export button.
Trac ticket: https://core.trac.wordpress.org/ticket/61575