Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
"name": "@fastify/type-provider-typebox",
"version": "6.1.0",
"description": "A Type Provider for Typebox over Fastify",
"module": "dist/esm/index.mjs",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.mjs",
"types": "./dist/cjs/index.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
},
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"peerDependencies": {
"typebox": "^1.0.13"
"typebox": "^1.1.14"
},
"scripts": {
"build:clean": "rimraf ./dist",
"build:cjs": "tsc --outDir dist/cjs --module CommonJS --moduleResolution Node10 --declaration --sourcemap false",
"build:cjs": "tsc --outDir dist/cjs --module CommonJS --moduleResolution bundler --declaration --sourcemap false",
"build:esm": "tsc --outDir dist/esm --module NodeNext --moduleResolution NodeNext --declaration --sourcemap false",
"build:post": "node post-build.js",
"build:test": "attw --pack .",
"build": "npm-run-all build:clean build:cjs build:esm build:post build:test",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"test:node": "node --test test/index.js",
"test:node": "node --test test/index.cjs",
"test:types": "tsd --files 'types/*'",
"test": "npm-run-all build test:node test:types",
"prepublishOnly": "npm run build"
Expand All @@ -38,6 +39,10 @@
"type": "git",
"url": "git+https://github.com/fastify/fastify-type-provider-typebox.git"
},
"files": [
"dist",
"index.ts"
],
"keywords": [
"typebox",
"fastify"
Expand Down Expand Up @@ -89,6 +94,6 @@
"npm-run-all": "^4.1.5",
"rimraf": "^6.0.1",
"tsd": "^0.33.0",
"typescript": "~5.9.3"
"typescript": "~6.0.2"
}
}
18 changes: 14 additions & 4 deletions post-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
//
// ------------------------------------------------------------------

const fs = require('node:fs')
const path = require('node:path')
import fs from 'node:fs'
import path from 'node:path'

const __dirname = import.meta.dirname

const distCjs = path.join(__dirname, 'dist', 'cjs')
const distEsm = path.join(__dirname, 'dist', 'esm')
Expand All @@ -24,10 +26,18 @@ const rename = (oldPath, newPath) => {
}
}

if (!fs.existsSync(distCjs)) {
fs.mkdirSync(distCjs, { recursive: true })
}
fs.writeFileSync(
path.join(distCjs, 'package.json'),
JSON.stringify({ type: 'commonjs' }, null, 2)
)

// --- ESM ---
rename(path.join(distEsm, 'index.js'), path.join(distEsm, 'index.mjs'))
rename(path.join(distEsm, 'index.d.ts'), path.join(distEsm, 'index.d.mts'))

// --- CJS ---
rename(path.join(distCjs, 'index.mjs'), path.join(distCjs, 'index.js'))
rename(path.join(distCjs, 'index.d.mts'), path.join(distCjs, 'index.d.ts'))
rename(path.join(distCjs, 'index.cjs'), path.join(distCjs, 'index.js'))
rename(path.join(distCjs, 'index.d.cts'), path.join(distCjs, 'index.d.ts'))
File renamed without changes.
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"compilerOptions": {
"outDir": "dist",
"sourceMap": true,
"declaration": true
"declaration": true,
"module": "Node16",
"moduleResolution": "Node16"
},
"exclude": ["./node_modules", "types/**/*.test-d.mts"]
}
Loading