-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Not supported for use in TypeScript, the default export init
is not of function type.
#5
Comments
Typescript resolve to main filed of package.json by default which is the entrypoint for Node.js. It doesn't have(require) a init function. import from the web entrypoint will fix the problem. I don't know how to make typecript use browser field for now. |
The npm package you published lacks the I'm not sure about your build process, but you need to declare the Here is an example: // package.json
{
"exports": {
".": {
"require": {
"types": "pkg/nodejs/jieba_rs_wasm.d.ts",
"default": "pkg/nodejs/jieba_rs_wasm.js"
},
"node": {
"types": "pkg/nodejs/jieba_rs_wasm.d.ts",
"default": "pkg/nodejs/jieba_rs_wasm.js"
},
"browser": {
"types": "pkg/web/jieba_rs_wasm.d.ts",
"default": "pkg/web/jieba_rs_wasm.js"
}
}
}
} |
ref: https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBMAdsGAaOBvOBjArvAXzgDMoIQ4ByAK2AFMAjAQwFoB3JgZxEoG4AofgHohcQLOJgQMjAWP+B-eUAUroFklQKP6gbwzAuEqBpzUBoyvyYcUCZDAAUASgH88JgESBaOUByyoC65QIg2gR0VAMSqBftUBm1oEkbQEB6gP6pgPo2gOSagKYW1ugwULh05sKiANpUDi4enpTolH7+WVQhEZRwALr8QA
The text was updated successfully, but these errors were encountered: