nx: angular 15 using withModuleFederation errors on startup

Current Behavior

On angular 14/nx 14, running an application with module federation (via withModuleFederation) works fine

Once upgraded to angular 15/nx 15, for whatever reason, I get a white screen and get the following errors:

Uncaught Error: Automatic publicPath is not supported in this browser

for both polyfills.js and main.js

Digging into the compiled js, I noticed with angular14, the area where it errors, it uses import.meta.url to check the url, and the url of bundle file exists. (see below)

image

But with angular 15/nx 15, the same code snippet area looks like this (see below). Notice its a variable (Er) that is just an object defined at top of the file. It doesn’t use import.meta.

image

This is the main difference I see between the 2 versions of angular/nx.

Here is the webpack config for the host app that is failing:

const { withModuleFederation } = require('@nrwl/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);

Side note:

We have a separate application in the same repo that runs just fine with the angular upgrade. We are not using the withModuleFederation util and rather setting it manually.

The webpack config of the app that works looks like this:

module.exports = {
  output: {
    uniqueName: 'shell',
    publicPath: 'auto',
    scriptType: 'text/javascript',
  },
  optimization: {
    runtimeChunk: false,
  },
  resolve: {
    alias: {
      ...sharedMappings.getAliases(),
    },
  },
  plugins: [
    new ModuleFederationPlugin({
      name: 'shell',
      filename: 'remoteEntry.js',
      exposes: suitesShellExposedEntrypoints('shell'),
      remotes: suitesShellAvailableRemotes['suitesShell'],
      shared: sharedShellLibs,
    }),
    new ExternalTemplateRemotesPlugin(),
    sharedMappings.getPlugin(),
    findReplaceAllScorpionEnvVars(),
  ],
};

Ideally I would like to continue using withModuleFederation without manually overriding too many options, but would like to better understand which configuration is different with webpack.

Expected Behavior

Be able to upgrade to Angular 15/ Nx 15 using webpack and withModuleFederation util without getting just a white screen when running that the application.

GitHub Repo

No response

Steps to Reproduce

  1. We have a large repo. will try to create a basic setup to see if it’s reproducible with empty app.

Nx Report

Node : 16.16.0
   OS   : darwin arm64
   pnpm : 7.30.3

   nx                      : 15.9.4
   @nrwl/js                : 15.9.4
   @nrwl/jest              : 15.9.4
   @nrwl/linter            : 15.9.4
   @nrwl/workspace         : 15.9.4
   @nrwl/angular           : 15.9.4
   @nrwl/cli               : 15.9.4
   @nrwl/cypress           : 15.9.4
   @nrwl/devkit            : 15.9.4
   @nrwl/eslint-plugin-nx  : 15.9.4
   @nrwl/node              : 15.9.4
   @nrwl/storybook         : 15.9.4
   @nrwl/tao               : 15.9.4
   @nrwl/web               : 15.9.4
   @nrwl/webpack           : 15.9.4
   @nrwl/nx-cloud          : 16.0.5
   typescript              : 4.9.5
   ---------------------------------------
   Community plugins:
   @ionic/angular        : 5.9.4
   @ngrx/component       : 15.3.0
   @ngrx/component-store : 15.3.0
   @ngrx/effects         : 15.3.0
   @ngrx/entity          : 15.3.0
   @ngrx/router-store    : 15.3.0
   @ngrx/store           : 15.3.0
   apollo-angular        : 4.2.1
   rxjs                  : 6.6.7
   @ngneat/spectator     : 10.0.1
   @ngrx/schematics      : 15.3.0
   @ngrx/store-devtools  : 15.3.0
   @nxext/capacitor      : 15.7.0
   @nxext/ionic-angular  : 15.7.0
   @storybook/angular    : 6.5.16
   ngx-build-plus        : 14.0.0

Failure Logs

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 42 (9 by maintainers)

Most upvoted comments

Yeah, I was worried about that. I’ll keep digging to see if i can find the root cause

Hi @etkachev Sorry for the delay on this.

I’ll be looking at this today