Skip to content

Provide a way to map entrypoint source files to entrypoint bundles #34027

Closed as not planned

Description

@eblocha

Command

build

Description

With a build configuration such as:

{
  "browser": "src/main.ts",
  "styles": ["src/styles.css"]
}

I would like to be able to map browser -> main-[hash].js and styles -> styles-[hash].css reliably after a build.

We are using Angular for micro-frontends. When these micro-frontends are deployed, we need to allow the shell application to discover the correct files for each app entry point. There is a service that tracks these mappings in a manifest, and the shell requests this manifest on startup. During deployment, we need to tell this service what the entry point files are.

Today, our only options to do this are to use filename heuristics or build with source maps and parse those to look for the sources field.

Describe the solution you'd like

The @angular/build:application builder should provide an option to output a file which can map these source file entrypoints to a corresponding output file.

Basic Example

{
  "browser": "src/main.ts",
  "styles": ["src/styles.css"],
  "manifest": true
}

Would generate in dist/app/browser/manifest.json

{
  "browser": "main-[hash].js",
  "styles": "styles-[hash].css"
}

Multiple Style Bundles

If you have multiple style bundles, it would split those in the manifest. This is important because fonts have to be loaded at the root of the document, but shadow-dom components used for custom elements need a separate bundle to load into their shadow root.

{
  "browser": "src/main.ts",
  "styles": [
    {
      "bundleName": "styles",
      "input": "src/styles.css"
    },
    {
      "bundleName": "fonts",
      "input": "src/fonts.scss"
    }
  ]
}

Manifest:

{
  "browser": "main-[hash].js",
  "styles": {
    "styles": "styles-[hash].css",
    "fonts": "fonts-[hash].css"
  }
}

Describe alternatives you've considered

  1. Use file name heuristics to guess which bundle files map to input sources. For example, look for a file name matching a regex like ^main-[^-].js$ for the main entry point, or ^styles-[^-].css$ for styles.
  • Angular may change the output file naming scheme, and the heuristic will no longer work.
  • There may be lazy chunks that happen to end up with a file name that matches the entry point pattern.
  1. Parse index.html for entry point files.
  2. Parse source maps and look for an entry in sources matching the entry point filename.
  • After optimization, certain entry files can be omitted from the sources array. For example, if two stylesheets have the same content, only one will be in the sources array.
// angular.json options
{
  // assume these two files have the same content
  "styles": ["styles-1.css", "styles-2.css"]
}

The build merges them and deduplicates the style, generating a sourcemap with sources like this:

{
  "sources": ["styles-2.css"]
}

Activity

  1. added
    gemini-triaged
    on Sep 6, 2026
  2. added this to the needsTriage milestone on Sep 6, 2026
  3. alan-agius4 commented on Sep 7, 2026

    @alan-agius4
    Collaborator

    Hi @eblocha,

    Thank you for opening this feature request.

    Generating custom manifest files for micro-frontend discovery is outside the scope of @angular/build:application. There is no single standardized format for micro-frontend manifests; different architectures, deployment services, and orchestrators (such as Module Federation, Native Federation, import maps, or custom shell loaders) expect different metadata structures, entry point mappings, and asset formats. Supporting and maintaining specific manifest schemas directly within the application builder would add unnecessary coupling and maintenance overhead.

    That said, you can already achieve this reliably today without relying on filename heuristics or parsing source maps by enabling the statsJson option (--stats-json or "statsJson": true in angular.json).

    When enabled, the builder generates browser-stats.json in your build output directory, which contains the standard esbuild metafile. The metafile provides a reliable mapping of all outputs and their corresponding source entry points via the outputs property:

    {
      "outputs": {
        "browser/main-A1B2C3D4.js": {
          "entryPoint": "src/main.ts",
          "inputs": { ... },
          "bytes": 123456
        },
        "browser/styles-E5F6G7H8.css": {
          "entryPoint": "src/styles.css",
          "inputs": { ... },
          "bytes": 45678
        }
      }
    }

    You can extract the exact mappings you need and generate your custom manifest.json via a lightweight post-build script (e.g., run as part of a postbuild npm script or CI step):

    import { readFileSync, writeFileSync } from 'node:fs';
    
    const stats = JSON.parse(readFileSync('dist/my-app/browser-stats.json', 'utf8'));
    const manifest = { styles: {} };
    
    for (const [outputPath, { entryPoint }] of Object.entries(stats.outputs)) {
      if (!entryPoint) {
        continue;
      }
    
      if (entryPoint === 'src/main.ts') {
        manifest.browser = outputPath;
      } else if (entryPoint.endsWith('.css') || entryPoint.endsWith('.scss')) {
        manifest.styles[entryPoint] = outputPath;
      }
    }
    
    writeFileSync('dist/my-app/manifest.json', JSON.stringify(manifest, null, 2));

    Because the required data is already exposed through standard build stats and the manifest schema is specific to your deployment setup, we won't be adding a built-in manifest generator option to the builder.

  4. angular-automatic-lock-bot commented on Oct 21, 2026

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular/buildgemini-triaged

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions