nrwl / nx-labs

A collection of Nx plugins
MIT License
139 stars 50 forks source link

Add rspack build profiling support #414

Open nathan-isaac opened 3 weeks ago

nathan-isaac commented 3 weeks ago

Since nx is using @rspack/core we can't use add the RSPACK_PROFILE environment variable, unless I'm missing something.

https://rspack.dev/contribute/development/profiling#tracing

Could we add nx support for rspack build profiling?

nathan-isaac commented 3 weeks ago

I did find that there is a rsdoctor plugin. Though, when I enable it and run the nx build command it kills the doctor server. I do see it starting up in the logs.

const { composePlugins, withNx, withReact } = require('@nx/rspack');
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');

module.exports = composePlugins(
  withNx(),
  withReact(),
  (config) => {
    config.plugins = [
      ...config.plugins,
      process.env.RSDOCTOR && new RsdoctorRspackPlugin(),
    ].filter(Boolean);
    return config;
  },
);

I did notice that a .rsdoctor folder in the app dist folder. I was able to use the rsdoctor-cli but for some reason it doesn't include any loaders or plugins.

pnpm rsdoctor analyze --profile ./dist/apps/example-app/.rsdoctor/manifest.json
image