Skip to content

Commit

Permalink
fix: extension build with pnpm is missing node_modules
Browse files Browse the repository at this point in the history
node_modules folder contains external dependencies that
cannot be included due to vite limitation.

Signed-off-by: Denis Golovin <[email protected]>
  • Loading branch information
dgolovin committed Sep 10, 2024
1 parent 06a3aea commit ecdd275
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .extfiles
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ LICENSE
icon.png
redhat-icon.woff2
README.md
dist/**
www/**
!**/yarn.lock
!dist/package.json
!dist/pnpm-lock.yaml
dist/**/**
www/**
46 changes: 27 additions & 19 deletions scripts/build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,38 @@ if (fs.existsSync(builtinDirectory)) {
}

// install external modules into dist folder
cproc.exec('pnpm add [email protected]', { cwd: './dist' }, (error, stdout, stderr) => {
cproc.exec('pnpm init', { cwd: './dist' }, (error, stdout, stderr) => {
if (error) {
console.log(stdout);
console.log(stderr);
throw error;
}

byline(fileStream)
.on('data', line => {
line.startsWith('!') ? excludedFiles.push(line.substring(1)) : includedFiles.push(line);
})
.on('error', () => {
throw new Error('Error reading .extfiles');
})
.on('end', () => {
includedFiles.push(zipDirectory); // add destination dir
mkdirp.sync(zipDirectory);
console.log(`Copying files to ${zipDirectory}`);
cp(includedFiles, { exclude: excludedFiles }, error => {
if (error) {
throw new Error('Error copying files', error);
}
console.log(`Zipping files to ${destFile}`);
zipper.sync.zip(zipDirectory).compress().save(destFile);
cproc.exec('pnpm install [email protected]', { cwd: './dist' }, (error, stdout, stderr) => {
if (error) {
console.log(stdout);
console.log(stderr);
throw error;
}

byline(fileStream)
.on('data', line => {
line.startsWith('!') ? excludedFiles.push(line.substring(1)) : includedFiles.push(line);
})
.on('error', () => {
throw new Error('Error reading .extfiles');
})
.on('end', () => {
includedFiles.push(zipDirectory); // add destination dir
mkdirp.sync(zipDirectory);
console.log(`Copying ${includedFiles} to ${zipDirectory}`);
cp(includedFiles, { exclude: excludedFiles }, error => {
if (error) {
throw new Error('Error copying files', error);
}
console.log(`Zipping files to ${destFile}`);
zipper.sync.zip(zipDirectory).compress().save(destFile);
});
});
});
});
});

0 comments on commit ecdd275

Please sign in to comment.