Skip to content

Commit

Permalink
fix ripple error with dynamic import
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Sep 7, 2023
1 parent 9576d50 commit dbf84f7
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { Compiler, Configuration, Stats } from 'webpack';
import type { Compiler, Stats } from 'webpack';
import { loadEsmModule } from '@teambit/angular-common';

interface WebpackLoggingCallback {
(stats: Stats, config: Configuration): void;
}

const PLUGIN_NAME = 'angular-stats-logger-plugin';

export class StatsLoggerPlugin {
Expand All @@ -13,11 +9,15 @@ export class StatsLoggerPlugin {
const logger = {
...console
};
// "Executed when the compilation has completed."
const { createWebpackLoggingCallback } = await loadEsmModule<typeof import('@angular-devkit/build-angular/src/webpack/utils/stats')>('@angular-devkit/build-angular/src/webpack/utils/stats');
const loggingCallback = createWebpackLoggingCallback({} as any, logger as any) as any;
compiler.hooks.done.tap(PLUGIN_NAME, (stats: Stats) => {
loggingCallback(stats, {stats: {logging: 'info', colors: true}});
});
try {
// "Executed when the compilation has completed."
const { createWebpackLoggingCallback } = await loadEsmModule('@angular-devkit/build-angular/src/webpack/utils/stats') as any;
const loggingCallback = createWebpackLoggingCallback({} as any, logger as any) as any;
compiler.hooks.done.tap(PLUGIN_NAME, (stats: Stats) => {
loggingCallback(stats, { stats: { logging: 'info', colors: true } });
});
} catch (e) {
// if it fails, just continue (we don't need logging to break the build)
}
}
}

0 comments on commit dbf84f7

Please sign in to comment.