Giter VIP home page Giter VIP logo

Comments (8)

Maggi64 avatar Maggi64 commented on July 28, 2024 1

Sounds good 👍 I might change the function to only create the TextEncoder object when actually needed.
I need to check benchmarks what impact this would have though.
Without tree-shaking (i.e. in tests) TextEncoder gets called without ever getting used.

from moderndash.

karol-f avatar karol-f commented on July 28, 2024 1

Without tree-shaking (i.e. in tests) TextEncoder gets called without ever getting used.

I will just add that tree-shaking is usually done only in production builds (as it's computation heavy), so I assume that moderndash, in dev mode, will break also in e.g. Next.js as it does two separate builds - for the server and for the browser.

from moderndash.

Maggi64 avatar Maggi64 commented on July 28, 2024 1

@karol-f Fixed in 991a1d9 v2.2.3

TextEncoder is only created when its needed in hash

You can close this issue if it works for you 👍

from moderndash.

Maggi64 avatar Maggi64 commented on July 28, 2024

Mhh TextEncoder should be a global and doesn't need an import.
https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder?retiredLocale=de

On the first glance it looks like an issue outside of moderndash. It only appeared now in v2.2.2 because I moved the TextEncoder to the outer scope. Before it was generated in the hash function itself.

@karol-f can you give me a reproducible repo on stackblitz for example?
I will look at it there.

from moderndash.

Maggi64 avatar Maggi64 commented on July 28, 2024

A google search showed me this, seems to be related: inrupt/solid-client-authn-js#1676

Seems like a jest issue. This probably fixes it for you: https://stackoverflow.com/a/68468204

from moderndash.

karol-f avatar karol-f commented on July 28, 2024

Thanks for the hints, I will try to resolve it myself with e.g. @inrupt/jest-jsdom-polyfills package.

from moderndash.

karol-f avatar karol-f commented on July 28, 2024

Importing @inrupt/jest-jsdom-polyfills in setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'] file worked for me.

I just wonder if we really need TextEncoder in Node environment (e.g. in tests or Next.js on server-side).
This did a trick for me, works in both environments (when only importing merge from moderndash):

var textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;

Obviously, this second way will fail if you actually will use some method with TextEncoder usage, but at least it won't break every time in Node, without pollyfill.

from moderndash.

karol-f avatar karol-f commented on July 28, 2024

I can confirm that it's working now :) Thank you!

from moderndash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.