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

SDK does not work outside of browser #68

Closed
Enngage opened this issue Jun 28, 2021 · 0 comments · Fixed by #82
Closed

SDK does not work outside of browser #68

Enngage opened this issue Jun 28, 2021 · 0 comments · Fixed by #82

Comments

@Enngage
Copy link
Member

Enngage commented Jun 28, 2021

Brief bug description

Using this SDK is problematic under node.js (e.g. when using Angular universal = SSR) because SDK directly invokes browser specific API - MutationObserver (https://github.com/Kentico/kontent-smart-link/blob/e173a36628ccfb851a0f54b93a965957b3d3e309/src/lib/NodeSmartLinkProvider.ts#L44)

In such cases you get ReferenceError: MutationObserver is not defined exception.

This SDK should check whether the API is available and use Polyfills (if available for our use case) or use different API alltogether specific to Node.js. When using API specific do Node.js, be sure to "exclude" this code publicly exported API that might be used in browser where this API is not available as it might prevent you from building the library with Typescript/Webpack etc.. Careful testing is needed for this to work both in node.js & browsers.

If none of this is possible, we should add a disclaimer that node.js is not supported, but I don't think that should be our goal as this should be quite common use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant