You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current JS build script outputs files with the following shape (example for English):
StemmerEnglish=function(){// ...}
In non-strict-mode (e.g. root-level non-modularized JavaScript), this automatically adds StemmerEnglish to the global scope, which is less-than-ideal but generally doesn't cause problems. However, in strict-mode (e.g. a JavaScript module), this throws Uncaught ReferenceError: StemmerEnglish is not defined. This makes it impossible to run on Deno, which always uses strict mode.
In addition, the JSDoc types added aren't picked up by TypeScript.
Is there interest in adding an ESM build, either as a replacement for or in addition to the current JS one? I've managed to hack one together in my fork (README, compilation logic, dynamic imports by locale code, tests), and it works nicely in Deno, newer versions of Node, and in-browser HTTP imports, with TypeScript-available types out of the box. I could probably work it into a PR with some effort (I don't know much C), but I'd need a steer on a couple of things:
Should there be separate builds for "global-scope JS" vs "ESM" vs "TypeScript" (see also New feature: Typescript compiler #155)? My feeling is that there's not much point having a separate TS build, as TS-compatible types can be supplied by JSDoc without any loss of JS compatibility. But it might be worthwhile keeping the old global-scope build for backward-compatibility, e.g. to continue supporting older versions of Nodejs.
If it's worthwhile having more than 1 JS/TS build, how should this be specified in CLI flags? E.g. supplying -esm as an additional flag along with -js, or -esm being a completely separate flag from -js?
Would something like getStemmerByLocale.mjs be considered valuable to include in the build, or should that be supplied by userland code? The advantage of including it in the build is that hard-coded dynamic imports are visible to static analysis, giving the performance advantage of lazily-loaded stemmers without causing the imports to be removed from bundles by overly-zealous downstream build tools. This is primarily useful for multilingual use cases. Requiring that logic to be supplied by userland code would require the consumer to add their own build step, based on the files in ./algorithms and the locale name mapping.
The current JS build script outputs files with the following shape (example for English):
In non-strict-mode (e.g. root-level non-modularized JavaScript), this automatically adds
StemmerEnglishto the global scope, which is less-than-ideal but generally doesn't cause problems. However, in strict-mode (e.g. a JavaScript module), this throwsUncaught ReferenceError: StemmerEnglish is not defined. This makes it impossible to run on Deno, which always uses strict mode.In addition, the JSDoc types added aren't picked up by TypeScript.
Is there interest in adding an ESM build, either as a replacement for or in addition to the current JS one? I've managed to hack one together in my fork (README, compilation logic, dynamic imports by locale code, tests), and it works nicely in Deno, newer versions of Node, and in-browser HTTP imports, with TypeScript-available types out of the box. I could probably work it into a PR with some effort (I don't know much C), but I'd need a steer on a couple of things:
-esmas an additional flag along with-js, or-esmbeing a completely separate flag from-js?getStemmerByLocale.mjsbe considered valuable to include in the build, or should that be supplied by userland code? The advantage of including it in the build is that hard-coded dynamic imports are visible to static analysis, giving the performance advantage of lazily-loaded stemmers without causing the imports to be removed from bundles by overly-zealous downstream build tools. This is primarily useful for multilingual use cases. Requiring that logic to be supplied by userland code would require the consumer to add their own build step, based on the files in./algorithmsand the locale name mapping.