-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
require() of ES Module @angular/core/fesm2022/core.mjs not supported #9376
Comments
Hi @zip-fa thank you for reporting! Haven't looked into Angular 17 yet but I'll try to reproduce this. Are you using some kind of SSR setup or does this happen out of the box? |
@Lms24 here is the repro: https://github.com/zip-fa/ng17-sentry-bug don't forget to run npm install with --force option :) |
Awesome, thank you!
I know, I'll bump the peer deps as soon as we figured this out ;) |
Workaround (only required for SSR)Okay, so I tried a couple of things and I think this can be narrowed down to our SDK being imported into server code:
If I manually declare // app.config.server.ts
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideClientHydration } from '@angular/platform-browser';
import { appConfig } from './app.config';
//import { appConfig } from './app.config';
const appConfigWithoutSentry: ApplicationConfig = {
providers: [provideRouter(routes), provideClientHydration()],
};
const serverConfig: ApplicationConfig = {
providers: [provideServerRendering()],
};
export const config = mergeApplicationConfig(
// appConfig,
appConfigWithoutSentry,
serverConfig
); What's important to know is that our SDK for Angular only works in the browser environment. It's not meant to be imported by the server (e.g. for SSR). We might expand angular SSR support in the future but we haven't looked into this a lot and additionally have a lot of other things going on. Some other observations:
|
In angular v17, when ssr option is enabled, vite starts to serve angular in ssr mode under the hood with |
@zip-fa do you have some pointers for what kind of checks? To me, it seems to me like the |
There was simple environmental check, which is currently broken in serve mode:
So i don't really know. Maybe you should consult with angular's core team |
I digged deeper today. I have already structure as you described, sentry got included only in app.config.browser.ts, but it executes under-the-hood in vite with application builder (which will be new default soon).
So there must be some kind of fix for this, or maybe new version of package which will support new reality (vite and esbuild). |
…ith SSR config (#9412) Adjust the entry points of `@sentry/angular-ivy`'s `package.json` to point directly to FESM2015 bundles (= bundled ESM2015 code) instead of the UMD bundles. This fixes an error when the old (no longer supported) UMD bundles were picked up by Vite in Angular apps with SSR config (#9376). A proper long term fix to this is to bump to Angular 15 in this package which we can only do in a new major.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/angular-ivy
SDK Version
7.75.1
Framework Version
17.0.0-rc.1
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
ng serve on esbuild-based builder in angular
Expected Result
Working angular project
Actual Result
Not working angular project :))
Logs, explanation: angular/angular-cli#26135
The text was updated successfully, but these errors were encountered: