Skip to content

Commit d38b0e6

Browse files
authored
Merge pull request #285 from db-ui/fix-ReferenceError-filename-is-not-defined
fix: `ReferenceError: __filename is not defined`
2 parents 4fd1522 + 4c1c2d0 commit d38b0e6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/generate-icon-fonts/svg-to-font.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { fileURLToPath } from 'node:url';
12
import path from "node:path";
23

34
import svgtofont from "svgtofont";
4-
import { OptionsType } from "../types";
5+
import { OptionsType } from "../types.js";
56
import { log } from "console";
67

78
const svgToFont = async (
@@ -11,7 +12,7 @@ const svgToFont = async (
1112
) => {
1213
const { fontName, debug, svgoOptions, outSVGReact, svgicons2svgfont } =
1314
options;
14-
const fileName = __filename;
15+
const fileName = fileURLToPath(import.meta.url);
1516
let lastSlashIndex = fileName.lastIndexOf("\\");
1617
if (lastSlashIndex === -1) {
1718
lastSlashIndex = fileName.lastIndexOf("/");

tsconfig.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"compilerOptions": {
33
"target": "esnext",
4-
"module": "commonjs",
4+
"module": "NodeNext",
55
"declaration": true,
66
"outDir": "dist",
7-
"moduleResolution": "node",
8-
"esModuleInterop": true,
7+
"moduleResolution": "NodeNext",
98
"experimentalDecorators": true,
109
"emitDecoratorMetadata": true,
1110

0 commit comments

Comments
 (0)