Skip to content

fix(js): export thModel - #1394

Merged
tushuhei merged 1 commit into
google:mainfrom
kwy404:fix-js-export-th-model
Sep 26, 2026
Merged

tushuhei merged 1 commit into
google:mainfrom
kwy404:fix-js-export-th-model

Conversation

@kwy404

@kwy404 kwy404 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

javascript/src/index.ts imports the Thai model for loadDefaultThaiParser, but only exports jaModel, zhHansModel and zhHantModel. The exports map in package.json also blocks deep imports, so require('budoux/dist/data/models/th.js') throws ERR_PACKAGE_PATH_NOT_EXPORTED. So there is no way to build a plain new Parser(thModel), for example inside a Web Worker as the README section "Working with Web Worker" describes for jaModel.

This adds thModel to the existing model export. Added a test that builds a Parser with the exported thModel and checks parser.parse('วันนี้อากาศดี') returns ['วัน', 'นี้', 'อากาศ', 'ดี'], the same as the Python parser and the README example. It fails before the change and passes after.

Tested with npm test (Node and Chromium) and npm run lint.

index.ts imports the Thai model for loadDefaultThaiParser but only
exported jaModel, zhHansModel and zhHantModel. Since the exports map
blocks deep imports, there was no way to build a plain `new Parser()`
with the Thai model, for example in a Web Worker as the README
describes. This exports thModel next to the other models.
@tushuhei
tushuhei merged commit 697aadb into google:main Sep 26, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants