'How to use __filename in angular library?

I have two angular 13 projects - an application and a library. In both projects I need to use __filename. To do it in the application I use "@angular-builders/custom-webpack:browser" builder with the custom webpack config:

export default (config: webpack.Configuration, options: CustomWebpackBrowserSchema, targetOptions: TargetOptions) => {
  config.node = {
    __filename: true,
    __dirname: true
  };
  return config;
}

However, I can't find a solution to use __filename in angular library. As I understand webpack is not used in library building.

Could anyone say, how to get __filename in the library, if it is possible.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source