Skip to content

Vite tree-shakes ix/asynciterable/todomstream away #382

Open
@mayorandrew

Description

@mayorandrew

First of all, huge thank you for this library. This is really a breath of fresh air for iterator processing in JavaScript which is otherwise a quite messy experience. Now when LLM reponses are streamed, I tend to use this more and more often.

Problem Description

I have a frontend project that is built with Vite, which internally uses a combination of rollup and esbuild for production builds.

There, I am using an AsyncIterableX.pipeThrough() module to interconnect the IxJS iterables with Web Streams API to do streaming JSON parsing.

This function is added to the prototype of AsyncIterableX as a side-effect of importing the ./src/asynciterable/todomstream.ts module:

https://github.com/ReactiveX/IxJS/blob/master/src/asynciterable/todomstream.ts#L230-L236

Unfortunately, rollup decides to remove this module away even if I explicitly import it, so I'm getting the following error in the production build:

TypeError: ds(...).pipeThrough is not a function

I am using IxJS v7.0.0

Solution Proposal

I was able to fix the problem locally by adjusting the sideEffects property of IxJS package.json file. Instead of setting it to false, I have explicitly specified the files with side-effects:

  "sideEffects": [
    "./asynciterable/todomstream.mjs",
    "./asynciterable/todomstream.js"
  ],

(Even though I use rollup, it seems that the webpack docs are still applicable for more details on the semantics of the sideEffects field).

This has solved the problem. I have created a PR. Please let me know if that fix is applicable, and if there are any other files with side-effects which could be included there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions