Skip to content

Commit d360566

Browse files
authored
fix: extension build with pnpm is missing node_modules (#290)
node_modules folder contains external dependencies that cannot be included due to vite limitation. Signed-off-by: Denis Golovin <[email protected]>
1 parent bc36f71 commit d360566

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

.extfiles

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ LICENSE
33
icon.png
44
redhat-icon.woff2
55
README.md
6-
dist/**
7-
www/**
8-
!**/yarn.lock
6+
!dist/package.json
7+
!dist/pnpm-lock.yaml
8+
dist/**/**
9+
www/**

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node-linker=hoisted

scripts/build.cjs

+27-19
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,38 @@ if (fs.existsSync(builtinDirectory)) {
4545
}
4646

4747
// install external modules into dist folder
48-
cproc.exec('pnpm add [email protected]', { cwd: './dist' }, (error, stdout, stderr) => {
48+
cproc.exec('pnpm init', { cwd: './dist' }, (error, stdout, stderr) => {
4949
if (error) {
5050
console.log(stdout);
5151
console.log(stderr);
5252
throw error;
5353
}
5454

55-
byline(fileStream)
56-
.on('data', line => {
57-
line.startsWith('!') ? excludedFiles.push(line.substring(1)) : includedFiles.push(line);
58-
})
59-
.on('error', () => {
60-
throw new Error('Error reading .extfiles');
61-
})
62-
.on('end', () => {
63-
includedFiles.push(zipDirectory); // add destination dir
64-
mkdirp.sync(zipDirectory);
65-
console.log(`Copying files to ${zipDirectory}`);
66-
cp(includedFiles, { exclude: excludedFiles }, error => {
67-
if (error) {
68-
throw new Error('Error copying files', error);
69-
}
70-
console.log(`Zipping files to ${destFile}`);
71-
zipper.sync.zip(zipDirectory).compress().save(destFile);
55+
cproc.exec('pnpm install [email protected]', { cwd: './dist' }, (error, stdout, stderr) => {
56+
if (error) {
57+
console.log(stdout);
58+
console.log(stderr);
59+
throw error;
60+
}
61+
62+
byline(fileStream)
63+
.on('data', line => {
64+
line.startsWith('!') ? excludedFiles.push(line.substring(1)) : includedFiles.push(line);
65+
})
66+
.on('error', () => {
67+
throw new Error('Error reading .extfiles');
68+
})
69+
.on('end', () => {
70+
includedFiles.push(zipDirectory); // add destination dir
71+
mkdirp.sync(zipDirectory);
72+
console.log(`Copying files to ${zipDirectory}`);
73+
cp(includedFiles, { exclude: excludedFiles }, error => {
74+
if (error) {
75+
throw new Error('Error copying files', error);
76+
}
77+
console.log(`Zipping files to ${destFile}`);
78+
zipper.sync.zip(zipDirectory).compress().save(destFile);
79+
});
7280
});
73-
});
81+
});
7482
});

0 commit comments

Comments
 (0)