nfroidure / ttf2woff2

Convert ttf files to woff2.
MIT License
302 stars 40 forks source link

Error: unexpected top-level await at node_modules/ttf2woff2/dist/index.js:9 #87

Open timint opened 1 week ago

timint commented 1 week ago

Error: unexpected top-level await at node_modules/ttf2woff2/dist/index.js:9

ttf2woff2 = (await import('bindings')).default('addon.node').convert;

Using Node v23.1.0. This package version 5 came as a dependency from gulp-iconfont. I tried upgrading to image2woff2 6.0.1 but the error remains.

From my gulpfile.mjs:

import iconfont from 'gulp-iconfont';

I also tried this without luck:

import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);

const iconfont = require('gulp-iconfont');
timint commented 3 days ago

This seems to be a compatibility breaker related to ESM and CommonJS. https://evertpot.com/using-top-level-await-is-bc-break/