angular: Angular SSR cannot use ESM modules (Domino compatibility issue)

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

I just created a fresh Angular universal app using Angular cli. it just works fine.

however, when I just add "type": "module" to package.json and serve again (with or without rebuilding the app again) it fails with the error Strict mode code may not include a with statement

reproduction steps 1- create a new Angular universal app ng new example && cd example && ng add @nguniversal/express-engine 2- run npm start -> npm run build:ssr && npm run serve:ssr (suceesed) 3- add "type": "module" and run npm run serve:ssr or npm start again (faild with Strict mode code may not include a with statement) 4- remove "type": "module" and run npm run serve:ssr without rebuilding the app (successed)

trials

  • remove ServerModule from imports[] im app/app.server.module.ts
  • remove export { renderModule } from '@angular/platform-server'; in app/main.server.ts
  • run npm start to rebuild the app (failed with the same error)

Please provide a link to a minimal reproduction of the bug

https://github.com/eng-dibo/issue-angular-esm or https://stackblitz.com/github/eng-dibo/issue-angular-esm

Please provide the exception or error you saw

`Strict mode code may not include a with statement` only with esm i.e: `type: module`

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 13.2.3
Node: 16.13.2
Package Manager: npm 8.1.2
OS: linux x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1302.3 (cli-only)
@angular-devkit/core         13.2.3 (cli-only)
@angular-devkit/schematics   13.2.3 (cli-only)
@schematics/angular          13.2.3 (cli-only)

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Just a quick update: the Domino-related issue was resolved and the code should be ESM-compatible now starting from v16 (you can test it using the 16.0.0-next.2 packages). Closing this ticket for now, please open a new ticket if the problem still exists in v16 packages.

@eng-dibo for the time being, this can be a workaround solution https://github.com/fgnass/domino/pull/180

Likely we will replace it with another implementation.

Hey @alan-agius4 ,

Are you planning to internalise that library? What is your the plan? Unfortunately, They have not touched their code for 2 years. https://github.com/fgnass/domino

Unfortunately, this is blocked on Domino.