Skip to content

nf(fix): Add support for external package.json wildcards - #963

Merged
Aukevanoost merged 8 commits into
angular-architects:mainfrom
Aukevanoost:issues/916
Nov 28, 2025
Merged

nf(fix): Add support for external package.json wildcards#963
Aukevanoost merged 8 commits into
angular-architects:mainfrom
Aukevanoost:issues/916

Conversation

@Aukevanoost

@Aukevanoost Aukevanoost commented Oct 14, 2025

Copy link
Copy Markdown
Collaborator

Proposal: Enhanced GLOB searching for secondary entry points.

Apparently, double asterisk (**) is not a thing for typescript/node exports:
src: https://hirok.io/posts/package-json-exports#exposing-all-package-files

This PR fixes the discovery of secondary entrypoints while respecting the package.json exports.

closes #916.

@Aukevanoost Aukevanoost changed the title fix: Add support for wildcards nf(fix): Add support for external package.json wildcards Oct 14, 2025
@Aukevanoost

Aukevanoost commented Oct 16, 2025

Copy link
Copy Markdown
Collaborator Author

I have been digging and the removeUnusedDeps is now fixed, but the share function is not handling the wildcards well. The issue seems to be in resolveSecondaries which translates the wildcard only to 1 level of folders, it should recursively resolve all paths that match the export from the package.json.

However, apparently, there is an order of precedence in the exports of a package.json. When you import a package, it will try the exports one by one until it resolves. We can't do that when we build export bundles... So we'll need to keep track of an "already resolved" Set for multiple wildcard patterns like angular/common:

"exports": {
    "./locales/global/*": {
      "default": "./locales/global/*.js"
    },
    "./locales/*": {
      "types": "./locales/*.d.ts",
      "default": "./locales/*.js"
    },
    "./package.json": {
      "default": "./package.json"
    },
    ".": {
      "types": "./index.d.ts",
      "default": "./fesm2022/common.mjs"
    },
    // more exports
}

We don't want to resolve global twice.

Working on it, this is just for administration.

@Aukevanoost

Copy link
Copy Markdown
Collaborator Author

Final considerations, it's now also accepting the asterisk when skipping entry points. E.g.

  shared: {
    ...share({                                    
      '@primeuix/themes': {
        singleton: true,
        strictVersion: true,
        requiredVersion: 'auto',
        includeSecondaries: {skip: "@primeuix/themes/aura/*"} // this creates only 1 entry point: @primeuix/themes/aura
      },
    }),
  },

By default, the remoteEntry.json files can be significantly bigger in size since it will include all found external secondary entryPoints. Therefore, the skip prop can be used to tweak which entry points should be externalized.

Also, small fix, but now all entrypoints of the library are excluded from the "externals" in the ESBuild. This is important because if the entryPoint "@primeuix/themes/aura" is in the externals list, all imports that start with this will be considered "resolvable" (like @primeuix/themes/aura/accordion). Now, this is a problem if the secondary is not bundled separately, e.g. because it is skipped as shown in the example above. So now every entry point within the bundle is indeed a separate runnable bundle.

@Aukevanoost
Aukevanoost merged commit 11dd80e into angular-architects:main Nov 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withNativeFederation with option ignoreUnusedDeps = false breaks angular locales resolving

1 participant