Skip to content

Commit

Permalink
build d.mts
Browse files Browse the repository at this point in the history
  • Loading branch information
laat committed Sep 10, 2024
1 parent 49e9874 commit e6ba4ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
8 changes: 8 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ function clean (groupNames) {
fse.removeSync(path.join(npmPath, `${bundleName}.js`))
fse.removeSync(path.join(npmPath, `${bundleName}.mjs`))
fse.removeSync(path.join(npmPath, `${bundleName}.d.ts`))
fse.removeSync(path.join(npmPath, `${bundleName}.d.mts`))
// Remove old npm jsx content
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.js`))
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.mjs`))
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.ts`))
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.mts`))

// Ensure npm folders exist (for icons it's '' which is falsy)
if (npmPath) fse.mkdirsSync(npmPath)
Expand Down Expand Up @@ -140,11 +142,13 @@ function buildIcons (groupName) {
fse.writeFileSync(path.join(npmPath, `${bundleName}.js`), icons.cjs)
fse.writeFileSync(path.join(npmPath, `${bundleName}.mjs`), icons.esm)
fse.writeFileSync(path.join(npmPath, `${bundleName}.d.ts`), icons.dtsLiteral)
fse.writeFileSync(path.join(npmPath, `${bundleName}.d.mts`), icons.dtsLiteral)

// Generate jsx and mjsx with types for icons and logos
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.js`), icons.cjsx)
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.mjs`), icons.esmx)
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.ts`), icons.dtsx)
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.mts`), icons.dtsx)

// Generate js/jsx artefacts for logo/large -files
if (groupName === 'logo') {
Expand All @@ -162,20 +166,24 @@ function buildIcons (groupName) {
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.js`))
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.mjs`))
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.d.ts`))
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.d.mts`))
// Remove old npm jsx content
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.js`))
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.mjs`))
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.ts`))
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.mts`))

// Generate js and mjs with types for icons and logos
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.js`), largeIcons.cjs)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.mjs`), largeIcons.esm)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.ts`), largeIcons.dtsLiteral)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.mts`), largeIcons.dtsLiteral)

// Generate jsx and mjsx with types for icons and logos
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.js`), largeIcons.cjsx)
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.mjs`), largeIcons.esmx)
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.ts`), largeIcons.dtsx)
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.mts`), largeIcons.dtsx)
}
} catch (error) {
console.error(`Failed to generate large js files for ${groupName} with error `, error)
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"./core-icons-iife.js",
"./core-icons.js",
"./core-icons.mjs",
"./core-icons.d.ts"
"./core-icons.d.ts",
"./core-icons.d.mts"
],
"exports": {
".": {
Expand All @@ -26,7 +27,7 @@
},
"import": {
"default": "./core-icons.mjs",
"types": "./core-icons.d.ts"
"types": "./core-icons.d.mts"
},
"browser": "./core-icons-iife.js"
},
Expand All @@ -37,7 +38,7 @@
},
"import": {
"default": "./logo/core-icons-logo.mjs",
"types": "./logo/core-icons-logo.d.ts"
"types": "./logo/core-icons-logo.d.mts"
}
},
"./logo/large": {
Expand All @@ -47,7 +48,7 @@
},
"import": {
"default": "./logo/large/core-icons-logo-large.mjs",
"types": "./logo/large/core-icons-logo-large.d.ts"
"types": "./logo/large/core-icons-logo-large.d.mts"
}
},
"./expressive": {
Expand All @@ -57,7 +58,7 @@
},
"import": {
"default": "./expressive/core-icons-expressive.mjs",
"types": "./expressive/core-icons-expressive.d.ts"
"types": "./expressive/core-icons-expressive.d.mts"
}
},
"./preview": {
Expand All @@ -67,7 +68,7 @@
},
"import": {
"default": "./preview/core-icons-preview.mjs",
"types": "./preview/core-icons-preview.d.ts"
"types": "./preview/core-icons-preview.d.mts"
}
},
"./jsx": {
Expand All @@ -77,7 +78,7 @@
},
"import": {
"default": "./jsx/core-icons.mjs",
"types": "./jsx/core-icons.d.ts"
"types": "./jsx/core-icons.d.mts"
}
},
"./jsx/logo": {
Expand All @@ -87,7 +88,7 @@
},
"import": {
"default": "./jsx/logo/core-icons-logo.mjs",
"types": "./jsx/logo/core-icons-logo.d.ts"
"types": "./jsx/logo/core-icons-logo.d.mts"
}
},
"./jsx/logo/large": {
Expand All @@ -97,7 +98,7 @@
},
"import": {
"default": "./jsx/logo/large/core-icons-logo-large.mjs",
"types": "./jsx/logo/large/core-icons-logo-large.d.ts"
"types": "./jsx/logo/large/core-icons-logo-large.d.mts"
}
},
"./jsx/expressive": {
Expand All @@ -107,7 +108,7 @@
},
"import": {
"default": "./jsx/expressive/core-icons-expressive.mjs",
"types": "./jsx/expressive/core-icons-expressive.d.ts"
"types": "./jsx/expressive/core-icons-expressive.d.mts"
}
},
"./jsx/preview": {
Expand All @@ -117,7 +118,7 @@
},
"import": {
"default": "./jsx/preview/core-icons-preview.mjs",
"types": "./jsx/preview/core-icons-preview.d.ts"
"types": "./jsx/preview/core-icons-preview.d.mts"
}
}
},
Expand Down

0 comments on commit e6ba4ee

Please sign in to comment.