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

Automatic gathering of used files for zip #1505

Open
st3h3n opened this issue Mar 7, 2025 · 2 comments
Open

Automatic gathering of used files for zip #1505

st3h3n opened this issue Mar 7, 2025 · 2 comments
Labels

Comments

@st3h3n
Copy link
Contributor

st3h3n commented Mar 7, 2025

Feature Request

I added the extension as a child to another project, kind of like a monorepo. The problem is that when I zip for Firefox it only includes the source files for the extension, but not files that the extension imports from the parent (or sibling) project. A possible way to do this might be; since Vite/Rollup should be aware of which files actually end up in the compiled output, zip could follow the paths and add those files.

Is your feature request related to a bug?

"N/A"

What are the alternatives?

Adding the files manually via defineConfig({ zip: {} }) which is very tedious and doesn't scale.

Additional context

"N/A"

@st3h3n st3h3n added the feature label Mar 7, 2025
@aklinker1
Copy link
Collaborator

aklinker1 commented Mar 8, 2025

If you're using a "package based" momorepo, not an integrated monorepo, vite is not aware of the sources of other local packages your extension depends on, only the already transpiled files of those packages. So no, there is no way for WXT to guarantee it will find all the files it needs.

You will have to tell it which files to zip. Config for controlling the root directory that is zipped already exists: zip.sourcesRoot. Then you can use glob patterns in zip.includeSources and zip.excludeSources.

Here's an example from a old version of WXT: https://github.com/anime-skip/player/blob/main/apps/extension/wxt.config.ts


Or, if you know vite is able to detect all the source files correctly in your project, you can dynamically generate the list yourself by hooking into the build process and changing which files get zipped. This can be done in a WXT module.

@st3h3n
Copy link
Contributor Author

st3h3n commented Mar 9, 2025

I don't use local packages.

if you know vite is able to detect all the source files correctly in your project, you can dynamically generate the list yourself by hooking into the build process and changing which files get zipped. This can be done in a WXT module.

Exactly. That's what I'm proposing for WXT to support natively. This wouldn't just help people with (integrated) monorepos, but it would also save people from having to manually delete all the files the don't need in the zipped source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants