question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular SSR cannot use ESM modules (Domino compatibility issue)

See original GitHub 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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
magyargergocommented, Sep 5, 2022

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

1reaction
alan-agius4commented, Mar 17, 2022

Likely we will replace it with another implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-side rendering (SSR) with Angular Universal
A Node.js Express web server compiles HTML pages with Universal based on client requests. To create the server-side application module, app.server.module ...
Read more >
node.js - How to fix Directory import '@angular-devkit\build ...
I faced this problem because I updated my project to Angular 13 using --legacy-peer-deps flag. Because of that, there were old dependencies ...
Read more >
webpack < 5 used to include polyfills for node.js core ...
I can't find a solution specifically for angular and I can't adapt them. ... node_modules/@storybook/store/dist/esm/index.js 10:0-28 10:0-28 @ .
Read more >
Angular Universal: real app problems
As a more straightforward solution, you can use the NgxSsrTimeoutModule module from the @ngx-ssr/timeout package. Import the module with the timeout value ...
Read more >
Swiper Changelog
a11y: fix JS error "swiper.a11y is undefined" (#6226) (02c1502) ... add "main" and "module" package fields (f228391); update dom7 and ssr-window to latest ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found