1
1
import { readFileSync } from "fs" ;
2
2
import { flatMapDeep } from "lodash" ;
3
+ import JSON5 from "json5" ;
3
4
import { Compiler , Entry } from "webpack" ;
4
5
import { bgScriptEntryErrorMsg , bgScriptManifestRequiredMsg } from "../messages/errors" ;
5
6
@@ -8,8 +9,8 @@ export function extractEntries(
8
9
manifestPath : string ,
9
10
webpackOutput : Compiler [ "options" ] [ "output" ] = { } ,
10
11
) : IEntriesOption {
11
- const manifestJson = JSON . parse ( readFileSync ( manifestPath ) . toString ( ) ) as IExtensionManifest ;
12
- const { background, content_scripts } = manifestJson ;
12
+ const manifestJson = JSON5 . parse ( readFileSync ( manifestPath ) . toString ( ) ) as IExtensionManifest ;
13
+ const { background, content_scripts : contentScripts } = manifestJson ;
13
14
const { filename } = webpackOutput ;
14
15
15
16
if ( ! filename ) {
@@ -31,9 +32,9 @@ export function extractEntries(
31
32
throw new TypeError ( bgScriptEntryErrorMsg . get ( ) ) ;
32
33
}
33
34
34
- const contentEntries : unknown = content_scripts
35
+ const contentEntries : unknown = contentScripts
35
36
? flatMapDeep ( Object . keys ( webpackEntry ) , ( entryName ) =>
36
- content_scripts . map ( ( { js } ) =>
37
+ contentScripts . map ( ( { js } ) =>
37
38
js . map ( ( contentItem ) => contentItem . replace ( toRemove , "" ) ) . filter ( ( contentItem ) => contentItem === entryName ) ,
38
39
) ,
39
40
)
0 commit comments