From ff20fb341f59d0d04a19b403444b373f3b5b071a Mon Sep 17 00:00:00 2001 From: Maximilian Franzke Date: Tue, 1 Oct 2024 12:25:52 +0200 Subject: [PATCH] fix: ReferenceError: __filename is not defined --- src/generate-icon-fonts/svg-to-font.ts | 5 +++-- tsconfig.json | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/generate-icon-fonts/svg-to-font.ts b/src/generate-icon-fonts/svg-to-font.ts index 862c17f..f715d0a 100644 --- a/src/generate-icon-fonts/svg-to-font.ts +++ b/src/generate-icon-fonts/svg-to-font.ts @@ -1,7 +1,8 @@ +import { fileURLToPath } from 'node:url'; import path from "node:path"; import svgtofont from "svgtofont"; -import { OptionsType } from "../types"; +import { OptionsType } from "../types.js"; import { log } from "console"; const svgToFont = async ( @@ -11,7 +12,7 @@ const svgToFont = async ( ) => { const { fontName, debug, svgoOptions, outSVGReact, svgicons2svgfont } = options; - const fileName = __filename; + const fileName = fileURLToPath(import.meta.url); let lastSlashIndex = fileName.lastIndexOf("\\"); if (lastSlashIndex === -1) { lastSlashIndex = fileName.lastIndexOf("/"); diff --git a/tsconfig.json b/tsconfig.json index 820e138..71c3688 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,10 @@ { "compilerOptions": { "target": "esnext", - "module": "commonjs", + "module": "Node16", "declaration": true, "outDir": "dist", - "moduleResolution": "node", - "esModuleInterop": true, + "moduleResolution": "Node16", "experimentalDecorators": true, "emitDecoratorMetadata": true,