Building error "data.trie" with rollup
ivantacca opened this issue · 4 comments
Hi, I am not able to build my project using rollup. I am constantly getting this error:
Error: ENOENT: no such file or directory, open '/Users/work/Desktop/font-parser-libraries/build/data.trie'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at /Users/work/Desktop/font-parser-libraries/build/fkbuild.umd.js:5546:65
at /Users/work/Desktop/font-parser-libraries/build/fkbuild.umd.js:2:82
at Object.<anonymous> (/Users/work/Desktop/font-parser-libraries/build/fkbuild.umd.js:5:3)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/work/Desktop/font-parser-libraries/build/data.trie'
}
I tried to isolate the problem creating another basic project with just an index.js
with the only purpose of testing the rollup build
index.js
import fontkit from 'fontkit'
console.log(fontkit)
export default class A {
constructor(){
console.log('hello from a')
}
}
rollup.config.js
import commonjs from '@rollup/plugin-commonjs';
import {nodeResolve} from '@rollup/plugin-node-resolve';
export default {
input: './index.js',
plugins: [
nodeResolve(),
commonjs(),
],
output: [
{ file: 'build/fkbuild.umd.js', format: 'umd', name: 'fkbuild' },
{ file: 'build/fkbuild.es.js', format: 'es' },
{ file: 'build/fkbuild.common.js', format: 'cjs' },
],
}
Then, I tested the build (umd
and cjs
)
var build = require('./build/fkbuild.common')
And finally got the error above.
I am new to rollup as well as node builds, so I apologize if I missed something clear.
Try fontkit-next package
I tried with fontkit-next and got the same result
Check Figma’s fork https://github.com/figma/fontkit/
Actually I found a solution to my problem:
I added this plugin to my rollup.config.js
import commonjs from '@rollup/plugin-commonjs';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import copy from 'rollup-plugin-copy'
export default {
input: './index.js',
plugins: [
nodeResolve(),
commonjs(),
copy({
targets: [
{ src: 'node_modules/fontkit/*.trie', dest: 'build' },
]
})
],
output: [
{ file: 'build/fknbuild.umd.js', format: 'umd', name: 'fknbuild' },
],
}
It allows the copy of the .trie
files that are not included in my build.
I don't really know what these files contains but it seems they are created by the module
But my build was neither including nor creating them