From ff20fb341f59d0d04a19b403444b373f3b5b071a Mon Sep 17 00:00:00 2001 From: Maximilian Franzke Date: Tue, 1 Oct 2024 12:25:52 +0200 Subject: [PATCH 1/2] 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, From 4c1c2d0ac82250ed5b82458d7da4dfc6c290a435 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke Date: Tue, 1 Oct 2024 12:43:52 +0200 Subject: [PATCH 2/2] refactor: let's adapt this to NodeNext --- tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 71c3688..0ddd5a3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "compilerOptions": { "target": "esnext", - "module": "Node16", + "module": "NodeNext", "declaration": true, "outDir": "dist", - "moduleResolution": "Node16", + "moduleResolution": "NodeNext", "experimentalDecorators": true, "emitDecoratorMetadata": true,