Skip to content

Commit

Permalink
Merge pull request #3872 from crazyserver/MOBILE-3947
Browse files Browse the repository at this point in the history
MOBILE-3947 chore: Fix require.context is not a function on APP INIT
  • Loading branch information
NoelDeMartin authored Nov 30, 2023
2 parents ffed38e + e7c5dcd commit 2b0d7ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/core/initializers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class CoreStorageService {
async initializeDatabase(): Promise<void> {
try {
await CoreApp.createTablesFromSchema(APP_SCHEMA);
} catch (e) {
} catch {
// Ignore errors.
}

Expand Down

0 comments on commit 2b0d7ef

Please sign in to comment.