-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Error: unexpected top-level await at node_modules/ttf2woff2/dist/index.js:9 #87
Comments
This seems to be a compatibility breaker related to ESM and CommonJS. |
From my understanding this is the line that caused
This error seemed to be irellevant of gulp-iconfont as I got it with the other gulp font packs as well using When rewriting the file like the following I get the libraries to load and run. index.ts import { YError, printStackTrace } from 'yerror';
import debug from 'debug';
import { env } from 'node:process';
const doDebug = debug('ttf2woff2');
const ttf2woff2Promise: Promise<(input: Buffer) => Buffer> = new Promise((resolve, reject) => {
let ttf2woff2: undefined | ((input: Buffer) => Buffer) = undefined;
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'native') {
import('bindings')
.then(bindings => {
ttf2woff2 = bindings.default('addon.node').convert;
doDebug('✅ Using native version.');
resolve(ttf2woff2);
})
.catch(err => {
doDebug('❌ Could not load the native version.', printStackTrace(err));
checkWasmVersion();
});
} else {
checkWasmVersion();
}
function checkWasmVersion() {
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'wasm') {
if (!ttf2woff2) {
import('../jssrc/index.js')
.then(module => {
ttf2woff2 = module.default;
doDebug('✅ Using WASM version.');
resolve(ttf2woff2);
})
.catch(err => {
doDebug('❌ Could not load the WASM version.', printStackTrace(err));
reject(new YError('E_UNABLE_TO_LOAD_TTF2WOFF2', env.TTF2WOFF2_VERSION));
});
}
} else {
reject(new YError('E_UNABLE_TO_LOAD_TTF2WOFF2', env.TTF2WOFF2_VERSION));
}
}
});
export default ttf2woff2Promise; But this just unlocked another problem. When specifying woff2 in the formats it stops with a gulp-ttf2woff2 Error:
|
Error: unexpected top-level await at node_modules/ttf2woff2/dist/index.js:9
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:
I also tried this without luck:
The text was updated successfully, but these errors were encountered: