contentful / node-apps-toolkit

A collection of helpers and utilities for creating NodeJS Contentful Apps
MIT License
13 stars 5 forks source link

__filename is not defined (ESM) #703

Open iDVB opened 1 month ago

iDVB commented 1 month ago

Package doesn't support ESM?

ReferenceError: __filename is not defined

node_modules/.pnpm/@contentful+node-apps-toolkit@2.8.2/node_modules/@contentful/node-apps-toolkit/lib/keys/get-management-token.js102:179
        defaultCache = new NodeCache();
    }
    const httpClientOpts = typeof opts.host !== 'undefined' ? { prefixUrl: opts.host } : {};
    return (0, exports.createGetManagementToken)((0, utils_1.createLogger)({ filename: __filename }), (0, utils_1.createHttpClient)(httpClientOpts), defaultCache)(privateKey, opts);
};
exports.getManagementToken = getManagementToken;

Should likely has an ESM supported build?

// Import the URL module to resolve file paths
import { fileURLToPath } from 'url'

// ESM replacement for __filename
const __filename = fileURLToPath(import.meta.url)
whitelisab commented 3 weeks ago

Hi @iDVB! Thanks for this feedback, I've created a ticket in our team's backlog and we will keep you updated on it's progress.