Skip to content

Commit

Permalink
[Fix][Vite] Fix error for index.js.map (#415)
Browse files Browse the repository at this point in the history
Address issue #414. Since
`index.js.map` is a json, when specifying string, we should use `\"`
instead of `"`.

Prior to this PR, we populate `const performanceNode =
"MLC_DUMMY_REQUIRE_VAR"`, this PR changes it to `const performanceNode =
\"MLC_DUMMY_REQUIRE_VAR\"`
  • Loading branch information
CharlieFRuan authored May 22, 2024
1 parent 67f9219 commit 7783e5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cleanup-index-js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sed -e s/"new (require('u' + 'rl').URL)('file:' + __filename).href"/"\"MLC_DUMMY
# For more see https://github.com/mlc-ai/web-llm/issues/258 and https://github.com/mlc-ai/web-llm/issues/127
sed -e s/"import require\$\$3 from 'perf_hooks';"/"const require\$\$3 = \"MLC_DUMMY_REQUIRE_VAR\""/g -i .backup lib/index.js
# Similarly replace `const performanceNode = require(\"perf_hooks\")` with `const performanceNode = "MLC_DUMMY_REQUIRE_VAR"`
sed -e s/'require(\\\"perf_hooks\\\")'/'\"MLC_DUMMY_REQUIRE_VAR\"'/g -i .backup lib/index.js.map
sed -e s/'require(\\\"perf_hooks\\\")'/'\\\"MLC_DUMMY_REQUIRE_VAR\\\"'/g -i .backup lib/index.js.map

# Cleanup backup files
rm lib/index.js.backup
Expand Down

0 comments on commit 7783e5a

Please sign in to comment.