Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 12 additions & 3 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,13 +922,20 @@ class LaunchEntryPointProcessor extends BaseProcessor {
constructor(manifest: Manifest) {
super(manifest);
if (manifest.main) {
this.entryPoints.add(util.normalize(path.join('extension', manifest.main)));
this.entryPoints.add(util.normalize(path.join('extension', this.appendJSExt(manifest.main))));
}
if (manifest.browser) {
this.entryPoints.add(util.normalize(path.join('extension', manifest.browser)));
this.entryPoints.add(util.normalize(path.join('extension', this.appendJSExt(manifest.browser))));
}
}

appendJSExt(filePath: string): string {
if (filePath.endsWith('.js')) {
return filePath;
}
return filePath + '.js';
}

onFile(file: IFile): Promise<IFile> {
this.entryPoints.delete(util.normalize(file.path));
return Promise.resolve(file);
Expand All @@ -937,7 +944,9 @@ class LaunchEntryPointProcessor extends BaseProcessor {
async onEnd(): Promise<void> {
if (this.entryPoints.size > 0) {
const files: string = [...this.entryPoints].join(',\n ');
throw new Error(`Extension entrypoint(s) missing. Make sure these files exist and aren't ignored by '.vscodeignore':\n ${files}`);
throw new Error(
`Extension entrypoint(s) missing. Make sure these files exist and aren't ignored by '.vscodeignore':\n ${files}`
);
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/test/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1796,20 +1796,27 @@ describe('toContentTypes', () => {

describe('LaunchEntryPointProcessor', () => {
it('should detect when declared entrypoint is not in package', async () => {
const manifest = createManifest({
main: 'main.js',
});
const manifest = createManifest({ main: 'main.js' });
const files = [{ path: 'extension/browser.js', contents: Buffer.from('') }];

let didErr = false;

try {
await _toVsixManifest(manifest, files);
} catch (err: any) {
const message = err.message;
didErr = message.includes('entrypoint(s) missing') && message.includes('main.js');
}

assert.ok(didErr);
});

it('should work even if .js extension is not used', async () => {
const manifest = createManifest({ main: 'out/src/extension' });
const files = [{ path: 'extension/out/src/extension.js', contents: Buffer.from('') }];
await _toVsixManifest(manifest, files);
});

it('should accept manifest if no entrypoints defined', async () => {
const manifest = createManifest({});
const files = [{ path: 'extension/something.js', contents: Buffer.from('') }];
Expand Down