File tree 2 files changed +22
-6
lines changed
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -922,13 +922,20 @@ class LaunchEntryPointProcessor extends BaseProcessor {
922
922
constructor ( manifest : Manifest ) {
923
923
super ( manifest ) ;
924
924
if ( manifest . main ) {
925
- this . entryPoints . add ( util . normalize ( path . join ( 'extension' , manifest . main ) ) ) ;
925
+ this . entryPoints . add ( util . normalize ( path . join ( 'extension' , this . appendJSExt ( manifest . main ) ) ) ) ;
926
926
}
927
927
if ( manifest . browser ) {
928
- this . entryPoints . add ( util . normalize ( path . join ( 'extension' , manifest . browser ) ) ) ;
928
+ this . entryPoints . add ( util . normalize ( path . join ( 'extension' , this . appendJSExt ( manifest . browser ) ) ) ) ;
929
929
}
930
930
}
931
931
932
+ appendJSExt ( filePath : string ) : string {
933
+ if ( filePath . endsWith ( '.js' ) ) {
934
+ return filePath ;
935
+ }
936
+ return filePath + '.js' ;
937
+ }
938
+
932
939
onFile ( file : IFile ) : Promise < IFile > {
933
940
this . entryPoints . delete ( util . normalize ( file . path ) ) ;
934
941
return Promise . resolve ( file ) ;
@@ -937,7 +944,9 @@ class LaunchEntryPointProcessor extends BaseProcessor {
937
944
async onEnd ( ) : Promise < void > {
938
945
if ( this . entryPoints . size > 0 ) {
939
946
const files : string = [ ...this . entryPoints ] . join ( ',\n ' ) ;
940
- throw new Error ( `Extension entrypoint(s) missing. Make sure these files exist and aren't ignored by '.vscodeignore':\n ${ files } ` ) ;
947
+ throw new Error (
948
+ `Extension entrypoint(s) missing. Make sure these files exist and aren't ignored by '.vscodeignore':\n ${ files } `
949
+ ) ;
941
950
}
942
951
}
943
952
}
Original file line number Diff line number Diff line change @@ -1796,20 +1796,27 @@ describe('toContentTypes', () => {
1796
1796
1797
1797
describe ( 'LaunchEntryPointProcessor' , ( ) => {
1798
1798
it ( 'should detect when declared entrypoint is not in package' , async ( ) => {
1799
- const manifest = createManifest ( {
1800
- main : 'main.js' ,
1801
- } ) ;
1799
+ const manifest = createManifest ( { main : 'main.js' } ) ;
1802
1800
const files = [ { path : 'extension/browser.js' , contents : Buffer . from ( '' ) } ] ;
1801
+
1803
1802
let didErr = false ;
1803
+
1804
1804
try {
1805
1805
await _toVsixManifest ( manifest , files ) ;
1806
1806
} catch ( err : any ) {
1807
1807
const message = err . message ;
1808
1808
didErr = message . includes ( 'entrypoint(s) missing' ) && message . includes ( 'main.js' ) ;
1809
1809
}
1810
+
1810
1811
assert . ok ( didErr ) ;
1811
1812
} ) ;
1812
1813
1814
+ it ( 'should work even if .js extension is not used' , async ( ) => {
1815
+ const manifest = createManifest ( { main : 'out/src/extension' } ) ;
1816
+ const files = [ { path : 'extension/out/src/extension.js' , contents : Buffer . from ( '' ) } ] ;
1817
+ await _toVsixManifest ( manifest , files ) ;
1818
+ } ) ;
1819
+
1813
1820
it ( 'should accept manifest if no entrypoints defined' , async ( ) => {
1814
1821
const manifest = createManifest ( { } ) ;
1815
1822
const files = [ { path : 'extension/something.js' , contents : Buffer . from ( '' ) } ] ;
You can’t perform that action at this time.
0 commit comments