Skip to content

Commit 5e7d488

Browse files
authored
Improve error message when a module cannot be bundled and exclude vs/nls from bundles (microsoft#152188)
1 parent 68433fb commit 5e7d488

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

build/gulpfile.editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const editorEntryPoints = [
3434
{
3535
name: 'vs/base/common/worker/simpleWorker',
3636
include: ['vs/editor/common/services/editorSimpleWorker'],
37+
exclude: ['vs/nls'],
3738
prepend: ['vs/loader.js'],
3839
append: ['vs/base/worker/workerMain'],
3940
dest: 'vs/base/worker/workerMain.js'

build/lib/bundle.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,18 @@ function emitEntryPoint(modulesMap, deps, entryPoint, includedModules, prepend,
298298
if (module.shim) {
299299
mainResult.sources.push(emitShimmedModule(c, deps[c], module.shim, module.path, contents));
300300
}
301-
else {
301+
else if (module.defineLocation) {
302302
mainResult.sources.push(emitNamedModule(c, module.defineLocation, module.path, contents));
303303
}
304+
else {
305+
const moduleCopy = {
306+
id: module.id,
307+
path: module.path,
308+
defineLocation: module.defineLocation,
309+
dependencies: module.dependencies
310+
};
311+
throw new Error(`Cannot bundle module '${module.id}' for entry point '${entryPoint}' because it has no shim and it lacks a defineLocation: ${JSON.stringify(moduleCopy)}`);
312+
}
304313
});
305314
Object.keys(usedPlugins).forEach((pluginName) => {
306315
const plugin = usedPlugins[pluginName];

build/lib/bundle.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface IPosition {
1515
interface IBuildModuleInfo {
1616
id: string;
1717
path: string;
18-
defineLocation: IPosition;
18+
defineLocation: IPosition | null;
1919
dependencies: string[];
2020
shim: string;
2121
exports: any;
@@ -444,8 +444,16 @@ function emitEntryPoint(
444444

445445
if (module.shim) {
446446
mainResult.sources.push(emitShimmedModule(c, deps[c], module.shim, module.path, contents));
447-
} else {
447+
} else if (module.defineLocation) {
448448
mainResult.sources.push(emitNamedModule(c, module.defineLocation, module.path, contents));
449+
} else {
450+
const moduleCopy = {
451+
id: module.id,
452+
path: module.path,
453+
defineLocation: module.defineLocation,
454+
dependencies: module.dependencies
455+
};
456+
throw new Error(`Cannot bundle module '${module.id}' for entry point '${entryPoint}' because it has no shim and it lacks a defineLocation: ${JSON.stringify(moduleCopy)}`);
449457
}
450458
});
451459

src/buildfile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ exports.base = [
3232
{
3333
name: 'vs/editor/common/services/editorSimpleWorker',
3434
include: ['vs/base/common/worker/simpleWorker'],
35+
exclude: ['vs/nls'],
3536
prepend: ['vs/loader.js', 'vs/nls.js'],
3637
append: ['vs/base/worker/workerMain'],
3738
dest: 'vs/base/worker/workerMain.js'
3839
},
3940
{
4041
name: 'vs/base/common/worker/simpleWorker',
42+
exclude: ['vs/nls'],
4143
}
4244
];
4345

0 commit comments

Comments
 (0)