Skip to content

Performance improvement: build and rebuild for node only when necessary #905

@asollberger

Description

@asollberger

For which library do you have a feature request?

native-federation

Information

We have a fairly large application (shell and 8 remote applications, some of them even nested remotes).
Working with it on a virtual PC is getting to be a problem, mostly a shared disk issue (even just a part of the application is hard to run).

I was looking around for possibilities to reduce build and rebuild times and found the four bundles/builds in build-for-federation.ts.

It seems to me that the calls for bundleShared and bundleSeparate for node are only necessary when doing server side rendering.

Question for you:
I tried to disable the splitting and could not get it to work properly (the building worked just fine, but I had runtime errors). Is there any reason why it's needed?

  const config: esbuild.BuildOptions = {
    entryPoints: entryPoints.map((ep) => ({
      in: ep.fileName,
      out: path.parse(ep.outName).name,
    })),
    outdir,
    entryNames: hash ? '[name]-[hash]' : '[name]',
    write: false,
    absWorkingDir,
    external,
    logLevel,
    bundle: true,
    sourcemap: dev,
    minify: !dev,
    supported: {
      'async-await': false,
      'object-rest-spread': false,
    },
    splitting: true, //kind === 'mapping-or-exposed',
    platform: platform ?? 'browser',
    format: 'esm',
    target: target,
    logLimit: kind === 'shared-package' ? 1 : 0,
    plugins: (plugins as any) || [
      createCompilerPlugin(
        pluginOptions.pluginOptions,
        pluginOptions.styleOptions
      ),
      ...(mappedPaths && mappedPaths.length > 0
        ? [createSharedMappingsPlugin(mappedPaths)]
        : []),
      commonjsPlugin(),
    ],
    define: {
      ...(!dev ? { ngDevMode: 'false' } : {}),
      ngJitMode: 'false',
    },
  };

Describe any alternatives/workarounds you're currently using

I added a check in my local version of native federation where these two bundles are only done if ssr is turned on, seems to work just fine.

Here's my suggestion: #904

I would be willing to submit a PR to fix this issue

  • Yes
  • No

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