Closed edwardnyc closed 3 weeks ago
i've published a package called fontmin-esm as a work around with this this branch for ESM support: https://github.com/ecomfe/fontmin/pull/96
how to use fontmin-esm, I have a error when use import Fontmin from
'fontmin-esm'` @ @Lonor
@VFVrPQ Hi I had the same issue as you so I ported fontmin to Typescript and target it as ESM/ES2020 but it is now a strict ES module my rep is https://github.com/highcanfly-club/fontminify I change the name for avoiding conflicts
for using:
npm i @sctg/fontminify
import Fontmin from '@sctg/fontminify';
const fontminify = new Fontmin()
.src('*.ttf')
.dest('./fonts');
fontminify.run(function (err, files) {
if (err) {
throw err;
}
console.log(files[0]);
// => { contents: <Buffer 00 01 00 ...> }
});
or in Typescript®
import Fontminify from '@sctg/fontminify';
import type {FontminifyFile} from '@sctg/fontminify';
const fontminify = new Fontminify()
.src('*.ttf')
.dest('./fonts');
fontminify.run(function (err:Error, files:FontminifyFile[]) {
if (err) {
throw err;
}
console.log(files[0]);
// => { contents: <Buffer 00 01 00 ...> }
});
CLI is full of bug with options…
@eltorio I got a error when I use @sctg/fontminify.
Uncaught TypeError: util.inherits is not a function at node_modules/_ordered-read-streams@1.0.1@ordered-read-streams/index.js (index.js:95:6) at __require2 (chunk-S5KM4IGW.js?v=1997ebc3:18:50) at node_modules/_glob-stream@6.1.0@glob-stream/index.js (index.js:3:15) at __require2 (chunk-S5KM4IGW.js?v=1997ebc3:18:50) at node_modules/_vinyl-fs@3.0.3@vinyl-fs/lib/src/index.js (index.js:3:10) at __require2 (chunk-S5KM4IGW.js?v=1997ebc3:18:50) at node_modules/_vinyl-fs@3.0.3@vinyl-fs/index.js (index.js:4:8) at __require2 (chunk-S5KM4IGW.js?v=1997ebc3:18:50) at node_modules/_@sctg_fontminify@1.0.1@@sctg/fontminify/index.js (index.js:13:11) at __require2 (chunk-S5KM4IGW.js?v=1997ebc3:18:50)
Do you have any plans to support ESM? It will be very helpful for vite developers