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

Not compatible with browsers #236

Closed
1 task
edwinveldhuizen opened this issue Mar 12, 2024 · 4 comments
Closed
1 task

Not compatible with browsers #236

edwinveldhuizen opened this issue Mar 12, 2024 · 4 comments
Labels

Comments

@edwinveldhuizen
Copy link

Description

We have a monorepo with ts.ed projects and nextjs projects.
Because we like the logger library, we have been trying to use it in nextjs as well.
With https://nextjs.org/docs/pages/building-your-application/optimizing/instrumentation we've been able to setup the server-side pretty easily with a custom logger.
We've also setup a custom logger for the browser, however due to creating a default instance in logger/exports and not giving the ability to import the Logger class on it's own it's throwing the following errors:

Uncaught TypeError: Cannot read properties of undefined (reading 'write')
    at <instance_members_initializer> (StdoutAppender.js:38:26)
    at new StdoutAppender (StdoutAppender.js:37:22)
    at LoggerAppenders.set (LoggerAppenders.js:49:26)
    at eval (VM23126 exports.js:9:6)
    at ../node_modules/@tsed/logger/lib/esm/logger/exports.js (_app.js?ts=1710256543066:8786:1)

Todos

  • Allow individual classes to be imported like import { Logger } from '@tsed/logger/Logger' bypassing running logger/exports.js in the browser
@Romakita
Copy link
Collaborator

Ok It could be poossible to solve by using exports condition like is it other tsed module. I’ll try to fix that asap.

@edwinveldhuizen
Copy link
Author

edwinveldhuizen commented Mar 12, 2024

@Romakita that would be awesome! Thanks for the amazingly swift reply as well 🙌

@Romakita
Copy link
Collaborator

@edwinveldhuizen This PR #237 add conditional exports. The bundler will be able to pick the correct compiled code for your env (browser) ;). You don't need to change your actual implementation ^^ (or maybe instrument webpack/vite/whatever, to use the correct alias).

See you :)

@Romakita
Copy link
Collaborator

🎉 This issue has been resolved in version 6.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants