ESM-only build (#4227)

Co-authored-by: Link <link20050703@gmail.com>
This commit is contained in:
Fleny
2025-08-22 19:48:28 +02:00
committed by GitHub
parent 2d5e2114c7
commit bd37023847
10 changed files with 23 additions and 76 deletions

View File

@@ -35,7 +35,7 @@
"typescript": "^5.9.2"
},
"engines": {
"node": ">=18.0.0"
"node": ">=20.19.0"
},
"lint-staged": {
"*": "biome check --no-errors-on-unmatched --write"

View File

@@ -2,12 +2,7 @@
"name": "benchmarks",
"version": "0.0.0",
"private": true,
"main": "./dist/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
"import": "./dist/index.js",
"types": "./dist/types/index.d.ts"
},
"exports": "./dist/index.js",
"type": "module",
"license": "Apache-2.0",
"repository": {
@@ -15,10 +10,10 @@
"url": "git+https://github.com/discordeno/discordeno.git"
},
"scripts": {
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"build": "swc src --strip-leading-paths --delete-dir-on-start --out-dir dist",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
"release-build": "yarn build && yarn build:type",
"check": "biome check --write",
"build": "swc src --strip-leading-paths --delete-dir-on-start --out-dir dist",
"build-message": "swc src/generateMessage.ts --strip-leading-paths -C sourceMaps=false --out-dir ../../scripts",
"bench": "node dist/index.js"
},

View File

@@ -1,13 +1,7 @@
{
"name": "@discordeno/bot",
"version": "21.0.0",
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
},
"exports": "./dist/index.js",
"type": "module",
"license": "Apache-2.0",
"repository": {
@@ -19,8 +13,8 @@
"!dist/.tsbuildinfo"
],
"scripts": {
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
"release-build": "yarn build && yarn build:type",
"check": "biome check --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'",

View File

@@ -1,13 +1,7 @@
{
"name": "discordeno",
"version": "21.0.0",
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
},
"exports": "./dist/index.js",
"type": "module",
"license": "Apache-2.0",
"repository": {
@@ -19,8 +13,8 @@
"!dist/.tsbuildinfo"
],
"scripts": {
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
"release-build": "yarn build && yarn build:type",
"check": "biome check --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",

View File

@@ -1,13 +1,7 @@
{
"name": "@discordeno/gateway",
"version": "21.0.0",
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
},
"exports": "./dist/index.js",
"type": "module",
"license": "Apache-2.0",
"repository": {
@@ -19,8 +13,8 @@
"!dist/.tsbuildinfo"
],
"scripts": {
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
"release-build": "yarn build && yarn build:type",
"check": "biome check --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'",

View File

@@ -1,13 +1,7 @@
{
"name": "@discordeno/rest",
"version": "21.0.0",
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
},
"exports": "./dist/index.js",
"type": "module",
"license": "Apache-2.0",
"repository": {
@@ -19,8 +13,8 @@
"!dist/.tsbuildinfo"
],
"scripts": {
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
"release-build": "yarn build && yarn build:type",
"check": "biome check --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'",

View File

@@ -1,13 +1,7 @@
{
"name": "@discordeno/types",
"version": "21.0.0",
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
},
"exports": "./dist/index.js",
"type": "module",
"license": "Apache-2.0",
"repository": {
@@ -19,8 +13,8 @@
"!dist/.tsbuildinfo"
],
"scripts": {
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
"release-build": "yarn build && yarn build:type",
"check": "biome check --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",

View File

@@ -1,13 +1,7 @@
{
"name": "@discordeno/utils",
"version": "21.0.0",
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
},
"exports": "./dist/index.js",
"type": "module",
"license": "Apache-2.0",
"repository": {
@@ -19,8 +13,8 @@
"!dist/.tsbuildinfo"
],
"scripts": {
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --skipDefaultLibCheck --declaration --emitDeclarationOnly --declarationDir dist/types",
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
"release-build": "yarn build && yarn build:type",
"check": "biome check --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",

View File

@@ -1,12 +0,0 @@
import { readdir, readFile, rm, writeFile } from 'node:fs/promises'
const files = await readdir('dist/cjs', { recursive: true })
const promises = files
.filter((f) => f.endsWith('.js'))
.map(async (file) => {
const content = await readFile(`dist/cjs/${file}`, 'utf-8')
await rm(`dist/cjs/${file}`)
await writeFile(`dist/cjs/${file.slice(0, -3)}.cjs`, content.replace(/\.js(?!on)/g, '.cjs'))
})
await Promise.all(promises)

View File

@@ -7,7 +7,7 @@
},
"build:type": {
"dependsOn": ["^build:type"],
"outputs": ["dist/types/**/*.d.ts", "dist/types/**/*.d.ts.map", "dist/tsconfig.tsbuildinfo"]
"outputs": ["dist/**/*.d.ts", "dist/**/*.d.ts.map", "dist/tsconfig.tsbuildinfo"]
},
"test:unit-coverage": {
"dependsOn": ["^build"],