web-llm icon indicating copy to clipboard operation
web-llm copied to clipboard

Issue with source map in v0.2.37 when running with Vite

Open felladrin opened this issue 1 year ago • 3 comments

When running the project with Vite, it's throwing this error: (It doesn't prevent Vite from running, it's just annoying)

  VITE v5.2.11  ready in 257 ms

  ➜  Local:   http://localhost:7860/
  ➜  Network: http://172.19.0.2:7860/
✘ [ERROR] Expected "," in source map but found "MLC_DUMMY_REQUIRE_VAR"

    node_modules/@mlc-ai/web-llm/lib/index.js.map:1:212952:
      1 │ ...st performanceNode = "MLC_DUMMY_REQUIRE_VAR";\r\n            ret...
        │                          ~~~~~~~~~~~~~~~~~~~~~
        ╵                          ,

  The source map "node_modules/@mlc-ai/web-llm/lib/index.js.map" was referenced by the file "node_modules/@mlc-ai/web-llm/lib/index.js" here:

    node_modules/@mlc-ai/web-llm/lib/index.js:8190:21:
      8190 │ //# sourceMappingURL=index.js.map
           ╵                      ~~~~~~~~~~~~
image

Temporary solution: remove the //# sourceMappingURL=index.js.map line from @mlc-ai/web-llm/lib/index.js before compiling and Vite won't throw any errors.


Extra info: The v0.2.35 didn't have this problem.

felladrin avatar May 22 '24 21:05 felladrin

Thanks for reporting the error, will send a fix soon

CharlieFRuan avatar May 22 '24 22:05 CharlieFRuan

Could you try 0.2.38? Should be fixed via https://github.com/mlc-ai/web-llm/pull/415. Apologies for the inconvenience

CharlieFRuan avatar May 22 '24 23:05 CharlieFRuan

Thanks for the quick response, @CharlieFRuan!

I've installed v0.2.38 and noticed a difference already, but now the error is in another place of index.js.map:

image

I've manually replaced all occurrences of "MLC_DUMMY_PATH" with \"MLC_DUMMY_PATH\" in the source map and confirmed it runs without that error. So using the same solution from #415 for this variable should work. (Proposed in #420)

felladrin avatar May 24 '24 08:05 felladrin

Sorry, @CharlieFRuan and @tqchen, It seems the fix on https://github.com/mlc-ai/web-llm/pull/420 didn't solve the problem with "MLC_DUMMY_PATH". I just confirmed that this issue is present on v0.2.39:

image

I also double-checked it on https://www.npmjs.com/package/@mlc-ai/web-llm?activeTab=code and we can see the issue is there on v0.2.39 release:

image

Can we re-open this issue, and could you confirm why the change on #420 didn't fix it?

felladrin avatar May 30 '24 22:05 felladrin

Ahh thanks for the catch; this should be due to how we need ' instead of ". Will send a patch now and fix in 0.2.40

CharlieFRuan avatar May 31 '24 00:05 CharlieFRuan

Could you try 0.2.40 which includes https://github.com/mlc-ai/web-llm/pull/440?

CharlieFRuan avatar May 31 '24 01:05 CharlieFRuan

Thank you! Now it's fixed! 🎉

Confirmed here:

image

And also by removing the workaround I had for the issue.

felladrin avatar May 31 '24 12:05 felladrin