Skip to content

Commit c5b07dd

Browse files
committed
switch to esm
1 parent 099b3d0 commit c5b07dd

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

generator.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const axios = require('axios')
1+
import fs from 'fs'
2+
import path from 'path'
3+
import axios from 'axios'
44

55
const GOOGLE_FONTS_URL =
66
'https://fonts.google.com/metadata/icons?key=material_symbols&incomplete=true'
@@ -41,7 +41,7 @@ function generatePropsFile() {
4141
}
4242
`
4343

44-
fs.writeFileSync(path.join(__dirname, 'src', 'types.ts'), typesFile)
44+
fs.writeFileSync(path.join(import.meta.dirname, 'src', 'types.ts'), typesFile)
4545
}
4646

4747
async function generateComponentsForAllFamilies(icon) {
@@ -64,7 +64,7 @@ async function generateComponent(icon, family, filled = false) {
6464
console.log(`Downloading ${name}`)
6565

6666
await fs.writeFileSync(
67-
path.join(__dirname, 'src', `${name}.tsx`),
67+
path.join(import.meta.dirname, 'src', `${name}.tsx`),
6868
mapSVGToTemplate(name, svg),
6969
)
7070
} catch {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"react"
1919
],
2020
"private": false,
21+
"type": "module",
2122
"publishConfig": {
2223
"access": "public"
2324
},

tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"compilerOptions": {
3-
"module": "CommonJS",
4-
"target": "ES5",
3+
"module": "ES2020",
4+
"target": "ES2020",
55
"jsx": "react",
6-
"moduleResolution": "Node",
6+
"moduleResolution": "Bundler",
77
"esModuleInterop": true,
88
"outDir": "./dist",
99
"declaration": true,

0 commit comments

Comments
 (0)