MOBILE-3947 chore: Fix require.context is not a function on APP INIT

main
Pau Ferrer Ocaña 2023-11-24 14:08:40 +01:00
parent ffed38ebfb
commit e7c5dcd6da
2 changed files with 12 additions and 2 deletions

View File

@ -21,7 +21,17 @@ import { APP_INITIALIZER, Provider } from '@angular/core';
* @returns List of providers.
*/
export function getInitializerProviders(): Provider[] {
const context = require.context('./', false, /\.ts$/);
if (!import.meta.webpackContext) {
return [];
}
const context = import.meta.webpackContext(
'./',
{
recursive: false,
regExp: /\.\/.*\.ts$/,
},
);
return context.keys().reduce((providers, fileName) => {
const name = (fileName.match(/^(?:\.\/)?(.+)\.ts$/) || [])[1];

View File

@ -48,7 +48,7 @@ export class CoreStorageService {
async initializeDatabase(): Promise<void> {
try {
await CoreApp.createTablesFromSchema(APP_SCHEMA);
} catch (e) {
} catch {
// Ignore errors.
}