text2svg
text2svg copied to clipboard
require('fs') dependency is not getting resolved with webpack build
hi
I tried to npm install with webpack and after making webpack.config.js if i run webpack command i get error for not resolving the dependency require('fs') in /node_modules/text2svg/index.js
could someone please resolve this for me
@s1728k This module is work with nodejs.
I have installed node js and using node js only please elaborate on your solution
fs
is a module in nodejs, so text2svg
should be used in server-side
i understand that.
while developing web apps we run web app in localhost which is an imitation of server side.
While the index.js has a require('fs') the problem with browserify and other methods isn't specific to the text2svg package per se but it's reliance on opentype.js and most specifically it's use of readFileSync() which won't work in a browser. Presumably, to 'fix' it to work in a browser would require some kind of workaround in opentype.js to use something like fetch or axios to retrieve the font file(s). Maybe an override?
I discovered that it's not opentype itself but how this package is calling it. I also discovered you don't need this package to convert type to svg, just use opentype.js. It already has a browser ready version with a cdn and one of the three load methods supports uris.