Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular SSR cannot use ESM modules (Domino compatibility issue) #45062

Closed
its-dibo opened this issue Feb 12, 2022 · 15 comments
Closed

Angular SSR cannot use ESM modules (Domino compatibility issue) #45062

its-dibo opened this issue Feb 12, 2022 · 15 comments
Assignees
Labels
area: server Issues related to server-side rendering bug P2 The issue is important to a large percentage of users, with a workaround
Milestone

Comments

@its-dibo
Copy link

its-dibo commented Feb 12, 2022

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

@alan-agius4 alan-agius4 added the area: server Issues related to server-side rendering label Feb 12, 2022
@ngbot ngbot bot added this to the needsTriage milestone Feb 12, 2022
@alan-agius4
Copy link
Contributor

Unfortunately, this is blocked on Domino.

@JoostK JoostK changed the title Angular fails with esm Angular SSR cannot use ESM modules Mar 7, 2022
@magyargergo
Copy link

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

@alan-agius4
Copy link
Contributor

alan-agius4 commented Mar 17, 2022

Likely we will replace it with another implementation.

@its-dibo
Copy link
Author

I upgraded to Angular v14 and the issue still occurs

@its-dibo
Copy link
Author

its-dibo commented Sep 4, 2022

any news?
@magyargergo @alan-agius4 @brad @abraham

@alan-agius4
Copy link
Contributor

alan-agius4 commented Sep 4, 2022

@eng-dibo, no as the issue is still open.

@its-dibo
Copy link
Author

its-dibo commented Sep 4, 2022

Likely we will replace it with another implementation.

as you mentioned, can we replace Domino with another implementation?

@magyargergo
Copy link

@eng-dibo for the time being, this can be a workaround solution fgnass/domino#180

@its-dibo
Copy link
Author

its-dibo commented Sep 5, 2022

@eng-dibo for the time being, this can be a workaround solution fgnass/domino#180

many thanks, hope it merged very soon

@itsmiracler
Copy link

the issue still occurs - angular14

@alxhub alxhub added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Nov 16, 2022
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Nov 16, 2022
@AndrewKushnir AndrewKushnir changed the title Angular SSR cannot use ESM modules Angular SSR cannot use ESM modules (Domino compatibility issue) Dec 21, 2022
@magyargergo
Copy link

I took a look at the webpack side and it seems that lib doesn't support "type": "module" from package.json. webpack/webpack#15198. I think, it will be necessary to pass a loader into the webpack config. It can load CommonJS resolvers though webpack/loader-runner#67.

@renatoaraujoc
Copy link

I tried to migrate my Nx Angular workspace to ESM, did everything right but the Universal Server cannot be started due to the Domino issue. I guess I have to go back CommonJS then? I'm using latest versions of everything (angular and universal). Node 16/18, none works.

Screenshot 2023-01-29 at 20 01 57

@AndrewKushnir AndrewKushnir added P2 The issue is important to a large percentage of users, with a workaround and removed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jan 30, 2023
@magyargergo
Copy link

I tried to migrate my Nx Angular workspace to ESM, did everything right but the Universal Server cannot be started due to the Domino issue. I guess I have to go back CommonJS then? I'm using latest versions of everything (angular and universal). Node 16/18, none works.

Screenshot 2023-01-29 at 20 01 57

It seems, they have been working on the fix already

@AndrewKushnir
Copy link
Contributor

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.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: server Issues related to server-side rendering bug P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

No branches or pull requests

8 participants