file-type
file-type copied to clipboard
Add CommonJS entry points
trafficstars
Just out of curiosity, as there are so many issues with legacy CommonJS projects, trying to import this pure ESM module. Would this solution help a bit?
I added 2 CommonJS require entry points to the export:
core.cjs, CommonJS default entry-pointnode.cjs, Node.js entry-points.
Each entry point provides a function to load (using loadFileType) the ESM module asynchronous for CommonJS use.
const { loadFileType } = require('file-type');
(async () => {
const { fileTypeFromFile } = await loadFileType(); // Load the ESM file-type module async
const type = await fileTypeFromFile('fixture.gif');
console.log(type);
})();
Would this help?
Related to #661 and many more issues