Closed felixmosh closed 2 years ago
I'm gonna experiment with ways we could provide a browser version. For now you could look at the config that fengari-web
uses in their webpack.config.js
: https://github.com/fengari-lua/fengari-web/blob/77d35f5e1516f431cbb96e165b4272f2fc9b0b3a/webpack.config.js#L36-L39
I published an experimental version you can try:
npm i ioredis-mock@alpha
import Redis from 'ioredis-mock/browser';
const redis = new Redis();
redis.set('foo', 'bar');
console.log(await redis.get('foo'));
It works with unpkg.com as well:
import Redis from 'https://unpkg.com/ioredis-mock@alpha';
Wow, thanks I will try it.
:tada: This issue has been resolved in version 6.1.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
It's still a bit experimental @felixmosh but if you find any bugs feel free to open a new issue 😄 It's passing the integration testing suite, but it's running in a jsdom env. I've tested manually in chrome but only on a few commands, as well as a little lua scripting. I haven't been able to get the tests that use stream-mock
up and running, nor tested stream commands yet ⚠️
Thanks for giving me the idea to do a browser bundle! 🎉
Thank you! I have a good progress with my project thanx to you 🙏🏼.
Will share it as soon it will be ready to see daylight.
Hi,
I've tested the browser version and it looks GOOOOOD.
I have only one issue with some lua
code which I'm not sure regarding the source.
This error comes from running addJob
lua script.
I guess that cmsgpack
is not defined, and I'm not sure where it comes from in the real usage.
Maybe you have an idea 🙏🏼
I've pushed my demo code to here: https://github.com/felixmosh/bull-board/tree/live-demo/examples/live-demo.
To run it run:
yarn install
yarn start
I've found the source, it looks like redis
comes with it https://redis.io/commands/eval#available-libraries
A possible solution can be using fengari-interop
in order to call msg packer, what do you think?
Cool demo @felixmosh!
Unfortunately lua is a bit of a black box to me, in fact its implementation is entirely community driven and I'm unable to help here.
What I can do however, is help you with flagging this so one of the lua experts in our community can help you out. I suggest we start by first identifying if this problem is only happening in the browser version of ioredis-mock
or if it's also a problem if you're using ioredis-lib/lib/index.js
in a node env
.
Then lets make a test case we can add to ioredis-mock/test/integration
and I'll make a new issue and pin it so our community is made aware of it :D
Thank you for the response, I will open a separate issue since this global cmsgpack
should be implemented in the mock. (it just like the global redis
object)
Trying to use it in a SvelteKit project with TypeScript I'm getting:
Could not find a declaration file for module 'ioredis-mock/browser'
The types work fine without the /browser
with the types from @types/ioredis-mock
.
Any ideas how this can be resolved?
Hi,
I'm working on some demo which runs inside a browser, I've thought that I will able to run
ioredis-mock
inside the browser (bundled with webpack), but it relays heavily on other node modules the problematic isfengari
.Do you have any pointers for me?