@@ -7,7 +7,7 @@ export interface WebpackBackendOptions {
7
7
8
8
export class WebpackBackend implements Module {
9
9
public readonly type = "backend" ;
10
- private jsons : __WebpackModuleApi . RequireContext = require . context ( "" ) ;
10
+ private jsons : __WebpackModuleApi . RequireContext | null = null ;
11
11
private keys : string [ ] = [ ] ;
12
12
constructor ( services : Services , options : WebpackBackendOptions = { context : undefined } ) {
13
13
this . init ( services , options ) ;
@@ -22,6 +22,16 @@ export class WebpackBackend implements Module {
22
22
23
23
public async read ( language : string , namespace : string , callback : ReadCallback ) : Promise < void > {
24
24
const builtKey = `./${ language } /${ namespace } .json` ;
25
+ if ( this . jsons == null ) {
26
+ callback (
27
+ new Error ( `No context given!` ) ,
28
+ // TODO: Fix this when types are up to date with newest implementation.
29
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
30
+ // @ts -ignore
31
+ null
32
+ ) ;
33
+ return ;
34
+ }
25
35
if ( this . keys . includes ( builtKey ) === false ) {
26
36
callback (
27
37
new Error ( `Namespace "${ namespace } " for language "${ language } " was not found!` ) ,
@@ -44,6 +54,16 @@ export class WebpackBackend implements Module {
44
54
return Promise . all (
45
55
languages . map ( async lang => {
46
56
const builtKey = `./${ lang } /${ namespace } .json` ;
57
+ if ( this . jsons == null ) {
58
+ callback (
59
+ new Error ( `No context given!` ) ,
60
+ // TODO: Fix this when types are up to date with newest implementation.
61
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
62
+ // @ts -ignore
63
+ null
64
+ ) ;
65
+ return ;
66
+ }
47
67
if ( this . keys . includes ( builtKey ) === false ) {
48
68
console . error ( new Error ( `Namespace "${ namespace } " for language "${ lang } " was not found!` ) ) ;
49
69
return ;
0 commit comments