@@ -7,7 +7,7 @@ export interface WebpackBackendOptions {
77
88export class WebpackBackend implements Module {
99 public readonly type = "backend" ;
10- private jsons : __WebpackModuleApi . RequireContext = require . context ( "" ) ;
10+ private jsons : __WebpackModuleApi . RequireContext | null = null ;
1111 private keys : string [ ] = [ ] ;
1212 constructor ( services : Services , options : WebpackBackendOptions = { context : undefined } ) {
1313 this . init ( services , options ) ;
@@ -22,6 +22,16 @@ export class WebpackBackend implements Module {
2222
2323 public async read ( language : string , namespace : string , callback : ReadCallback ) : Promise < void > {
2424 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+ }
2535 if ( this . keys . includes ( builtKey ) === false ) {
2636 callback (
2737 new Error ( `Namespace "${ namespace } " for language "${ language } " was not found!` ) ,
@@ -44,6 +54,16 @@ export class WebpackBackend implements Module {
4454 return Promise . all (
4555 languages . map ( async lang => {
4656 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+ }
4767 if ( this . keys . includes ( builtKey ) === false ) {
4868 console . error ( new Error ( `Namespace "${ namespace } " for language "${ lang } " was not found!` ) ) ;
4969 return ;
0 commit comments