chaklim / hkscs_unicode_converter

Convert Unicode characters to HKSCS-2016
MIT License
6 stars 2 forks source link

does not work on browser (fs.readFileSync is not a function) #2

Closed miklcct closed 3 years ago

miklcct commented 3 years ago

I'm trying to use this package in a browser through snowpack. Even with node polyfill on it still doesn't work, saying

Uncaught TypeError: fs.readFileSync is not a function
    at tsvFile2json (index.js:89)
    at index.js:126
    at Array.forEach (<anonymous>)
    at index.js:121

This is my snowpack.json

{
    "mount" : {
        "src" : "/"
    },
    "buildOptions" : {
        "sourceMaps" : true,
        "clean" : true
    },
    "devOptions" : {
        "open" : "none"
    },
    "installOptions" : {
        "sourceMap" : true,
        "polyfillNode" : true
    },
    "plugins": [
        "@snowpack/plugin-typescript",
        [
            "@snowpack/plugin-run-script",
            {
                "cmd" : "eslint .",
                "watch" : "watch \"$1\""
            }
        ]
    ]
}
chaklim commented 3 years ago

The original implementation was trying to convert string on the server side (because those data files are large) The newest commit should fix that somewhat, but I think it is still not suggest to do that on client side 🤓