Skip to content

Can not find module 'pino-std-serializers' on Electron windows app #2331

@roddc

Description

@roddc

I'm trying to integrate pino in my Electron app, I made the pino as externals in rspack, but I can't install the app because of Can not find module 'pino-std-serializers'. How do I fix this? This my bundler config, I wrote a custom plugin to load pino module

const pinoWorkerPlugin = (): RsbuildPlugin => ({
  name: 'pino-worker-plugin',
  setup(api) {
    // Add the path override for pino worker
    api.onBeforeBuild(() => {
      const pinoWorkerPath = getPinoWorkerPath();
      if (pinoWorkerPath) {
        (
          globalThis as { __bundlerPathsOverrides?: Record<string, string> }
        ).__bundlerPathsOverrides = {
          'pino-worker': pinoWorkerPath,
        };
      }
    });

    api.modifyRspackConfig((config) => {
      return {
        ...config,
        externals: [
          ...(Array.isArray(config.externals) ? config.externals : []),
          {
            pino: 'pino',
            'pino-pretty': 'pino-pretty',
            'pino-roll': 'pino-roll',
            'pino-std-serializers': 'pino-std-serializers',
          },
        ],
        experiments: {
          ...config.experiments,
          outputModule: true,
        },
      };
    });
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions