chore(release): dual ESM/CJS build via tsup; fix packaging; 26.07.0-beta.0
Packaging was broken for consumers: `main` resolved to a nonexistent
dist/index.js (tsc emitted dist/src/index.js), and the tarball shipped
tests, benches and sources. Build with tsup to emit CJS + ESM (+ types)
behind an `exports` map so `require` and `import` both resolve; a
createRequire banner keeps the lazy require('ws')/require('busboy') working
under ESM. Add the `files` allowlist and a `prepublishOnly` gate.
Bump to the first CalVer beta, published under the npm `beta` dist-tag.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
4 files changed
+3117
-7
No files matched your search
Generated
+3045
File diff suppressed because it is too large.
Load diff
+48
-5
@@ -1,46 +1,89 @@
|
|||||||
{
|
{
|
||||||
"name": "@green-tea/core",
|
"name": "@green-tea/core",
|
||||||
"version": "0.0.0",
|
"version": "26.07.0-beta.0",
|
||||||
"description": "Declarative, type-safe HTTP framework. The pipeline is a graph, not a middleware chain.",
|
"description": "Declarative, type-safe HTTP framework. The pipeline is a graph, not a middleware chain.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"main": "dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"module": "./dist/index.mjs",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": {
|
||||||
|
"types": "./dist/index.d.mts",
|
||||||
|
"default": "./dist/index.mjs"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"default": "./dist/index.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"README.md",
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"LICENSE"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.json",
|
"build": "tsup",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:dev": "vitest",
|
"test:dev": "vitest",
|
||||||
"typecheck": "tsc --noEmit -p tsconfig.json",
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
||||||
"typecheck:bench": "tsc --noEmit -p bench/tsconfig.json",
|
"typecheck:bench": "tsc --noEmit -p bench/tsconfig.json",
|
||||||
"bench": "tsx bench/run.ts"
|
"lint": "eslint src",
|
||||||
|
"lint:fix": "eslint src --fix",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\"",
|
||||||
|
"format:check": "prettier --check \"src/**/*.ts\"",
|
||||||
|
"docs:dev": "npm --prefix website run dev",
|
||||||
|
"docs:build": "npm --prefix website run build",
|
||||||
|
"complexity": "ccts src",
|
||||||
|
"complexity:check": "node scripts/check-complexity.mjs",
|
||||||
|
"complexity:cyclomatic": "cyclomatic-complexity \"src/**/*.ts\" -tw 15 -te 25",
|
||||||
|
"bench": "tsx bench/run.ts",
|
||||||
|
"prepublishOnly": "npm run lint && npm run complexity:check && npm run typecheck && npm test && npm run build",
|
||||||
|
"prepare": "git config core.hooksPath .githooks || true"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"reflect-metadata": "0.2.2"
|
"reflect-metadata": "0.2.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
"busboy": "^1.6.0",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
|
"busboy": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.39.4",
|
||||||
"@nestjs/common": "^11.1.27",
|
"@nestjs/common": "^11.1.27",
|
||||||
"@nestjs/core": "^11.1.27",
|
"@nestjs/core": "^11.1.27",
|
||||||
"@nestjs/platform-express": "^11.1.27",
|
"@nestjs/platform-express": "^11.1.27",
|
||||||
"@nestjs/platform-fastify": "^11.1.27",
|
"@nestjs/platform-fastify": "^11.1.27",
|
||||||
|
"@stylistic/eslint-plugin": "^5.10.0",
|
||||||
"@types/autocannon": "^7.12.7",
|
"@types/autocannon": "^7.12.7",
|
||||||
|
"@types/busboy": "^1.5.4",
|
||||||
"@types/express": "^5.0.6",
|
"@types/express": "^5.0.6",
|
||||||
"@types/node": "^18.19.0",
|
"@types/node": "^18.19.0",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"autocannon": "^8.0.0",
|
"autocannon": "^8.0.0",
|
||||||
|
"busboy": "^1.6.0",
|
||||||
|
"cognitive-complexity-ts": "^0.8.2",
|
||||||
|
"eslint": "^9.39.4",
|
||||||
"express": "^5.2.1",
|
"express": "^5.2.1",
|
||||||
"fastify": "^5.10.0",
|
"fastify": "^5.10.0",
|
||||||
"graphql": "^16.9.0",
|
"graphql": "^16.9.0",
|
||||||
|
"prettier": "^3.9.4",
|
||||||
"rxjs": "^7.8.2",
|
"rxjs": "^7.8.2",
|
||||||
|
"tsup": "^8.5.1",
|
||||||
"tsx": "^4.23.0",
|
"tsx": "^4.23.0",
|
||||||
"typescript": "^5.5.0",
|
"typescript": "^5.5.0",
|
||||||
|
"typescript-eslint": "^8.63.0",
|
||||||
"vitest": "^2.0.0",
|
"vitest": "^2.0.0",
|
||||||
"ws": "^8.21.0"
|
"ws": "^8.21.0"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { expect, test } from 'vitest';
|
import { expect, test } from 'vitest';
|
||||||
import { VERSION } from '../src/index';
|
import { VERSION } from '../src/index';
|
||||||
|
|
||||||
test('package loads and exposes VERSION', () => {
|
test('package loads and exposes a CalVer VERSION', () => {
|
||||||
expect(VERSION).toBe('0.0.0');
|
expect(VERSION).toMatch(/^\d{2}\.\d{2}\.\d+(-beta\.\d+)?$/);
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { defineConfig } from 'tsup';
|
||||||
|
|
||||||
|
// Dual build: CJS (dist/index.js) + ESM (dist/index.mjs) + type declarations, from one entry.
|
||||||
|
// tsup injects a createRequire shim into the ESM output so the lazy require('ws') / require('busboy')
|
||||||
|
// (optional peer deps) keep working there. reflect-metadata and the peer deps stay external.
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ['src/index.ts'],
|
||||||
|
format: ['cjs', 'esm'],
|
||||||
|
dts: true,
|
||||||
|
clean: true,
|
||||||
|
sourcemap: true,
|
||||||
|
target: 'node18',
|
||||||
|
// Give the ESM output a real `require` (via createRequire) so the lazy require('ws') / require('busboy')
|
||||||
|
// (optional peer deps) resolve instead of hitting esbuild's "Dynamic require not supported" stub.
|
||||||
|
esbuildOptions(options, context) {
|
||||||
|
if (context.format === 'esm') {
|
||||||
|
options.banner = {
|
||||||
|
js: "import { createRequire as _createRequire } from 'node:module'; const require = _createRequire(import.meta.url);",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in new issue
Block a user