Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/wxt/src/core/zip.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { InlineConfig } from '../types';
import path from 'node:path';
import { execSync } from 'node:child_process';
import { mkdir, readFile } from 'node:fs/promises';
import { createWriteStream } from 'node:fs';
import { safeFilename } from './utils/strings';
Expand Down Expand Up @@ -115,15 +116,32 @@ async function zipDir(
},
): Promise<void> {
const archive = new JSZip();
const files = (
await glob(['**/*', ...(options?.include || [])], {

const globFiles = () =>
glob(['**/*', ...(options?.include || [])], {
cwd: directory,
// Ignore node_modules, otherwise this glob step takes forever
ignore: ['**/node_modules'],
onlyFiles: true,
expandDirectories: false,
});

let allFiles: string[];
try {
allFiles = execSync('git ls-files --recurse-submodules', {
cwd: directory,
encoding: 'utf-8',
})
).filter((relativePath) => {
.split('\n')
.filter(Boolean);
} catch {
allFiles = [];
}
if (allFiles.length === 0) {
allFiles = await globFiles();
}

const files = allFiles.filter((relativePath) => {
return (
picomatchMultiple(relativePath, options?.include) ||
!picomatchMultiple(relativePath, options?.exclude)
Expand Down