Skip to content

Commit

Permalink
fix(@angular/build): address rxjs undefined issues during SSR prebund…
Browse files Browse the repository at this point in the history
…ling

Replacing the paths to ESM in Vite can cause prebundling to fail in some cases, resulting in errors similar to the following:

```
12:55:12 PM [vite] Error when evaluating SSR module /chunk-CHB4JJIP.mjs:
|- TypeError: Cannot read properties of undefined (reading 'Subject')
    at eval (//src/app/shared/snackbar/snackbar.service.ts:2:25)
    at async instantiateModule (file:////node_modules/vite/dist/node/chunks/dep-BcXSligG.js:53408:5)

12:55:12 PM [vite] Error when evaluating SSR module /chunk-GQZ5BKXC.mjs:
|- TypeError: Cannot read properties of undefined (reading 'Subject')
    at eval (//src/app/shared/snackbar/snackbar.service.ts:2:25)
    at async instantiateModule (file:////node_modules/vite/dist/node/chunks/dep-BcXSligG.js:53408:5)
```

Closes: #27907
  • Loading branch information
alan-agius4 committed Jun 24, 2024
1 parent fd65792 commit 3e359da
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions packages/angular/build/src/builders/dev-server/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
BuildOutputFileType,
type ExternalResultMetadata,
JavaScriptTransformer,
createRxjsEsmResolutionPlugin,
getFeatureSupport,
getSupportedBrowsers,
isZonelessApp,
Expand Down Expand Up @@ -659,10 +658,6 @@ function getDepOptimizationConfig({
},
];

if (ssr) {
plugins.unshift(createRxjsEsmResolutionPlugin() as ViteEsBuildPlugin);
}

return {
// Exclude any explicitly defined dependencies (currently build defined externals)
exclude,
Expand Down

0 comments on commit 3e359da

Please sign in to comment.