Skip to content
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

Support ESM #99

Open
edwardnyc opened this issue Nov 29, 2021 · 4 comments
Open

Support ESM #99

edwardnyc opened this issue Nov 29, 2021 · 4 comments

Comments

@edwardnyc
Copy link

Do you have any plans to support ESM? It will be very helpful for vite developers

@la3rence
Copy link

la3rence commented Sep 4, 2022

i've published a package called fontmin-esm as a work around with this this branch for ESM support: #96

@VFVrPQ
Copy link

VFVrPQ commented Oct 9, 2022

how to use fontmin-esm, I have a error when use import Fontmin from 'fontmin-esm'` @ @lonor

@eltorio
Copy link

eltorio commented Oct 12, 2022

@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…

@VFVrPQ
Copy link

VFVrPQ commented Feb 7, 2023

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants