Merge pull request #3872 from crazyserver/MOBILE-3947

MOBILE-3947 chore: Fix require.context is not a function on APP INIT
main
Noel De Martin 2023-11-30 15:01:12 +01:00 committed by GitHub
commit 2b0d7ef12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.
}