Angular SSR cannot use ESM modules (Domino compatibility issue)
See original GitHub issueWhich @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
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (3 by maintainers)
Top GitHub Comments
@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.