-
Notifications
You must be signed in to change notification settings - Fork 212
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
Bundling with webpack does not work #67
Comments
I have the same issue any help |
Is there a trace available that explains where that error is thrown? |
In pdfmake we using brfs transformation ( see https://github.com/bpampuch/pdfmake/blob/33df9bbec76b358bec8d08bc49a1d2892445a3fa/webpack.config.js#L63 ). And then no external files are required. |
@Pomax Here's a stack trace:
|
I got it working by installing and then in the module: {
loaders: [
...loaders,
{enforce: 'post', test: /fontkit[\/\\]index.js$/, loader: "transform?brfs"},
{enforce: 'post', test: /unicode-properties[\/\\]index.js$/, loader: "transform?brfs"},
{enforce: 'post', test: /linebreak[\/\\]src[\/\\]linebreaker.js/, loader: "transform?brfs"}
]
}, I hope this helps. |
Hello, I got fs is undefined when using transform-loader?brfs in fontkit. How do you guys resolve this issue? |
Looking at https://github.com/webpack-contrib/transform-loader#webpack-2-config-example, it feels like the confs shown so far are not quite in line with how |
@albertoforni suggestion helps.
Are there any plans to implement a solution, that works without these workarounds? |
See foliojs/fontkit#67 Proposed solutions (adt. webpack config rules) do not help.
I don't really want to mess with my config just to get this to work in the browser, this should work out of the box :( I had no idea how to modify the webpack config via chainWebpack (I'm trying to use fontkit in a Vue app that uses Vue-CLI), but the below seems to work – it eliminates the The error still occurs when trying to call module.exports = {
chainWebpack: config => {
config.module
.rule('eslint')
.use('eslint-loader')
.tap(opts => ({ ...opts, emitWarning: true }));
config.module
.rule('fontkit')
.test(/fontkit[\/\\]index.js$/)
.use('transform-loader')
.loader("transform-loader?brfs")
config.module
.rule('unicode-properties')
.test(/unicode-properties[\/\\]index.js$/)
.use('transform-loader')
.loader("transform-loader?brfs")
config.module
.rule('linebreak')
.test(/linebreak[\/\\]src[\/\\]linebreaker.js/)
.use('transform-loader')
.loader("transform-loader?brfs")
// The above trying to replicate this:
// {enforce: 'post', test: /fontkit[\/\\]index.js$/, loader: "transform?brfs"},
// {enforce: 'post', test: /unicode-properties[\/\\]index.js$/, loader: "transform?brfs"},
// {enforce: 'post', test: /linebreak[\/\\]src[\/\\]linebreaker.js/, loader: "transform?brfs"}
}
} And then async openFromFile(file) {
const arrayBuffer = await file.arrayBuffer();
const f = fontkit.create(new Buffer(arrayBuffer));
} |
Try fontkit-next package. It has this PR applied and should work |
I don't think this is an adequate solution. |
at the very least, I'd say "see if it works with esbuild instead" given the monster that webpack is these days, and given how much faster (and arguably better) esbuild is. That said, the way fontkit works it's entirely likely that still won't get you to something that works without running the .trie data build yourself as an explicit step in your build. |
The following worked for me:
As described by webpack-node-externals:
That library is helpful to handle all
|
Hi,
running fontkit (and pdfkit) in an expressjs app works fine locally, but when I'm building it with webpack, it returns:
Error: ENOENT: no such file or directory, open '/var/www/backend/data.trie'
This is my webpack config:
When I copy the file
data.trie
from thenode_modules
folder to the same directory where I run the node app, it continues, but the same problem appears withuse.trie
then.Any idea how to solve it?
The text was updated successfully, but these errors were encountered: