Comments (8)
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.
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.
@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.
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.
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.
Thanks for the hints, I will try to resolve it myself with e.g. @inrupt/jest-jsdom-polyfills
package.
from moderndash.
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.
I can confirm that it's working now :) Thank you!
from moderndash.
Related Issues (20)
- Add possibility to wait until the queue finishes HOT 3
- Non-constructing `object.set`
- Shouldn't `hotscript` be in the main dependencies since it's imported in `dist/index.d.ts`? HOT 2
- Bundle hotscript types HOT 1
- Feature request - `mergeWith` HOT 3
- Feature request: debounce.pending() HOT 2
- Feature request - `deepFreeze` HOT 1
- Return the result of the last `throttle` invocation HOT 3
- Feature request - `curry`
- PlainObject not working with Interfaces HOT 3
- Feature request - `truncate` HOT 2
- Deprecate array `group` HOT 2
- Feature request - Array/concat HOT 5
- Feature request - clone HOT 3
- Error: Unexpected token '??=' HOT 2
- splitWordsRegex fails on iOS 16 HOT 6
- T39 Decorators
- Switch to mutations instead of copy HOT 1
- `takeRightWhile` | Improve performance HOT 1
- `set` | Incorrect type if value is replaced by array
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moderndash.