Closed MarketingPip closed 1 month ago
Thanks for your question. In my experience, separate browser builds for npm packages are becoming obsolete. Modern build tools like esbuild, webpack, and others can efficiently handle library compilation for browser environments. Did you face a specific challenge when using this package in browser?
@vladholubiev - correct a ESM build would be ideal. Which for that to work we would need a loader etc for (fs) in the browser.
Ideally would like to just be able to grab this from esm.sh etc - but currently get error from esm.sh - due to no FS supported in browser (on their end)
Where do you see that error? I can open https://esm.sh/@shelf/text-normalizer@1.1.0 without any issues. It works fine for me. Also I don't see where we use FS module in the code.
@vladholubiev - file system is being used here.
Error thrown is:
Uncaught Error: [esm.sh] "node:fs" is not supported in browser environment.
at n (node_fs.js:1:20)
at Object.V [as readFileSync] (node_fs.js:1:958)
at new N (english-spelling.js:13:43)
at new D (english.js:15:33)
To reproduce this issue load a CodePen etc (browser based environment - ESM.sh loads bundles based on device headers....)
import EnglishTextNormalizer from "https://esm.sh/@shelf/text-normalizer"
const normalizer = new EnglishTextNormalizer.EnglishTextNormalizer()
console.log(normalizer.normalize("Let's")); // Output: let us
console.log(normalizer.normalize("he's like")); // Output: he is like
You can resolve this issue by simply just using a import statement directly to the file and support ESM.
import {EnglishTextNormalizer} from "https://esm.sh/@shelf/text-normalizer"
const normalizer = new EnglishTextNormalizer()
console.log(normalizer.normalize("Let's ")); // Output: let us
console.log(normalizer.normalize("he's like!")); // Output: he is like
@vladholubiev - awesome little gift pretty well to me (and everyone else obviously lol). Thank you very much! :D
By chance could we get browser support added to this?