-
Notifications
You must be signed in to change notification settings - Fork 39
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
'ReferenceError: define is not defined' in dotnet SpaServices angular template with SSR #48
Comments
Hey there! 👋
|
@MarkPieszak thank you for your reply but unfortunately this is not solving the problem 😕 I got the same error with module set to es2015. |
@MarkPieszak do you have any progress on this? |
Not yet I'll have to try and find some time to look deeper into this but it seems like an underlying issue with application-insightsjs and how it's being bundled, hmm 🤔 |
Just wondering if you get the same issue with the latest version of this package? |
same issue with 5.0.5 for me. I added the define function to the test spec. Not sure its a good sulution overall ...
|
It seems like right now that might be the only way to fix the error, it looks like the library itself still has this issue Open :( |
Did this workaround solved the issue ? where exactly should we add this line (window as any).define = () => {}; ?? |
I am trying to use the library with the dotnet angular template provided by the aspnet templating team.
I am using the aspnet 2.1 with angular 5.2 version of the template and v4.0.2 of
@markpieszak/ng-application-insights
.I did everything exactly as stated in the documentation.
I have a shared AppModule and one for the server and another one for the browser. During ssr only the server one and the shared one used. I load the appinsights module in the browser AppModule.
I am injecting the AppInsightsService through the injector only if it is running in the browser.
Still, I get an error during prerendering:
The problem occurs at
applicationinsights-js\bundle\ai.module.js:187:1
, so this line is the problematic one:define("JavaScriptSDK.Module/AppInsightsModule", ["require", "exports"], function (require, exports)
.Just to be sure I have tried the https://github.com/MarkPieszak/aspnetcore-angular2-universal starter project and it works fine with this module, so the problem only occurs with Microsoft's template.
I have created a repro repository here: https://github.com/dominikfoldi/AngularSSRAppInsightsRepro
If you comment out the injection of the AppInsightsService in
app.component.ts
the error is gone, but otherwise it fails during SSR.@MarkPieszak or others do you have any idea how to resolve this?
The text was updated successfully, but these errors were encountered: