Skip to content

Commit 8c73711

Browse files
author
Tajudeen
committed
Add React build file verification to prevent blank screen issue
- Add verification step after compilation to ensure React files exist in out-build/ - Add verification step after bundling to ensure React files exist in out-vscode/ - Add verification step after minification to ensure React files exist in out-vscode-min/ - These checks will fail the build early with clear error messages if React files are missing - Prevents shipping apps with blank screen issue caused by missing React components
1 parent b5e7cba commit 8c73711

2 files changed

Lines changed: 91 additions & 3 deletions

File tree

build/gulpfile.compile.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ const buildReactTask = task.define('build-react', () => {
3838
});
3939
});
4040

41+
/**
42+
* Task to verify React build files exist after compilation
43+
*/
44+
const verifyReactBuildTask = task.define('verify-react-build', () => {
45+
const fs = require('fs');
46+
const path = require('path');
47+
const reactOutPath = path.join(__dirname, '../out-build/vs/workbench/contrib/cortexide/browser/react/out');
48+
49+
if (!fs.existsSync(reactOutPath)) {
50+
throw new Error(`React build output directory does not exist: ${reactOutPath}`);
51+
}
52+
53+
const files = fs.readdirSync(reactOutPath);
54+
const jsFiles = files.filter(f => f.endsWith('.js'));
55+
56+
if (jsFiles.length === 0) {
57+
throw new Error(`No React build files found in ${reactOutPath}. Expected at least one .js file.`);
58+
}
59+
60+
// allow-any-unicode-next-line
61+
console.log(`✅ Verified ${jsFiles.length} React build files exist in out-build/`);
62+
return Promise.resolve();
63+
});
64+
4165
/**
4266
* @param {boolean} disableMangle
4367
*/
@@ -47,7 +71,8 @@ function makeCompileBuildTask(disableMangle) {
4771
date.writeISODate('out-build'),
4872
compilation.compileApiProposalNamesTask,
4973
buildReactTask, // Build React components before compiling
50-
compilation.compileTask('src', 'out-build', true, { disableMangle })
74+
compilation.compileTask('src', 'out-build', true, { disableMangle }),
75+
verifyReactBuildTask // Verify React files are preserved after compilation
5176
);
5277
}
5378

build/gulpfile.vscode.js

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,36 @@ const bootstrapEntryPoints = [
125125
'out-build/bootstrap-fork.js'
126126
];
127127

128+
/**
129+
* Task to verify React build files exist after bundling
130+
*/
131+
const verifyReactFilesAfterBundleTask = task.define('verify-react-files-after-bundle', () => {
132+
const fs = require('fs');
133+
const path = require('path');
134+
const reactOutPath = path.join(__dirname, '../out-vscode/vs/workbench/contrib/cortexide/browser/react/out');
135+
136+
if (!fs.existsSync(reactOutPath)) {
137+
// allow-any-unicode-next-line
138+
console.error(`❌ React build output directory does not exist: ${reactOutPath}`);
139+
console.error('React files were not copied during bundling. This will cause a blank screen!');
140+
throw new Error(`React build output directory does not exist: ${reactOutPath}`);
141+
}
142+
143+
const files = fs.readdirSync(reactOutPath);
144+
const jsFiles = files.filter(f => f.endsWith('.js'));
145+
146+
if (jsFiles.length === 0) {
147+
// allow-any-unicode-next-line
148+
console.error(`❌ No React build files found in ${reactOutPath}`);
149+
console.error('React files were not copied during bundling. This will cause a blank screen!');
150+
throw new Error(`No React build files found in ${reactOutPath}. Expected at least one .js file.`);
151+
}
152+
153+
// allow-any-unicode-next-line
154+
console.log(`✅ Verified ${jsFiles.length} React build files exist in out-vscode/ after bundling`);
155+
return Promise.resolve();
156+
});
157+
128158
const bundleVSCodeTask = task.define('bundle-vscode', task.series(
129159
util.rimraf('out-vscode'),
130160
// Optimize: bundles source files automatically based on
@@ -144,15 +174,48 @@ const bundleVSCodeTask = task.define('bundle-vscode', task.series(
144174
skipTSBoilerplateRemoval: entryPoint => entryPoint === 'vs/code/electron-browser/workbench/workbench'
145175
}
146176
}
147-
)
177+
),
178+
verifyReactFilesAfterBundleTask // Verify React files are present after bundling
148179
));
149180
gulp.task(bundleVSCodeTask);
150181

151182
const sourceMappingURLBase = `https://main.vscode-cdn.net/sourcemaps/${commit}`;
183+
184+
/**
185+
* Task to verify React build files exist after minification
186+
*/
187+
const verifyReactFilesAfterMinifyTask = task.define('verify-react-files-after-minify', () => {
188+
const fs = require('fs');
189+
const path = require('path');
190+
const reactOutPath = path.join(__dirname, '../out-vscode-min/vs/workbench/contrib/cortexide/browser/react/out');
191+
192+
if (!fs.existsSync(reactOutPath)) {
193+
// allow-any-unicode-next-line
194+
console.error(`❌ React build output directory does not exist: ${reactOutPath}`);
195+
console.error('This will cause a blank screen in the packaged app!');
196+
throw new Error(`React build output directory does not exist: ${reactOutPath}`);
197+
}
198+
199+
const files = fs.readdirSync(reactOutPath);
200+
const jsFiles = files.filter(f => f.endsWith('.js'));
201+
202+
if (jsFiles.length === 0) {
203+
// allow-any-unicode-next-line
204+
console.error(`❌ No React build files found in ${reactOutPath}`);
205+
console.error('This will cause a blank screen in the packaged app!');
206+
throw new Error(`No React build files found in ${reactOutPath}. Expected at least one .js file.`);
207+
}
208+
209+
// allow-any-unicode-next-line
210+
console.log(`✅ Verified ${jsFiles.length} React build files exist in out-vscode-min/`);
211+
return Promise.resolve();
212+
});
213+
152214
const minifyVSCodeTask = task.define('minify-vscode', task.series(
153215
bundleVSCodeTask,
154216
util.rimraf('out-vscode-min'),
155-
optimize.minifyTask('out-vscode', `${sourceMappingURLBase}/core`)
217+
optimize.minifyTask('out-vscode', `${sourceMappingURLBase}/core`),
218+
verifyReactFilesAfterMinifyTask // Verify React files are present after minification
156219
));
157220
gulp.task(minifyVSCodeTask);
158221

0 commit comments

Comments
 (0)