diff --git a/package.json b/package.json index 1e774116..0b5c8a1b 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,88 @@ { "name": "itty-router", - "version": "4.0.9", + "version": "4.0.10-next.3", "description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.", "type": "module", - "main": "./index.js", + "main": "index.js", + "module": "index.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": "./index.js", + "require": "./cjs/index.js", + "types": "./index.d.ts" + }, + "./createCors": { + "import": "./createCors.js", + "require": "./cjs/createCors.js", + "types": "./createCors.d.ts" + }, + "./createResponse": { + "import": "./createResponse.js", + "require": "./cjs/createResponse.js", + "types": "./createResponse.d.ts" + }, + "./error": { + "import": "./error.js", + "require": "./cjs/error.js", + "types": "./error.d.ts" + }, + "./html": { + "import": "./html.js", + "require": "./cjs/html.js", + "types": "./html.d.ts" + }, + "./jpeg": { + "import": "./jpeg.js", + "require": "./cjs/jpeg.js", + "types": "./jpeg.d.ts" + }, + "./png": { + "import": "./png.js", + "require": "./cjs/png.js", + "types": "./png.d.ts" + }, + "./Router": { + "import": "./Router.js", + "require": "./cjs/Router.js", + "types": "./Router.d.ts" + }, + "./status": { + "import": "./status.js", + "require": "./cjs/status.js", + "types": "./status.d.ts" + }, + "./text": { + "import": "./text.js", + "require": "./cjs/text.js", + "types": "./text.d.ts" + }, + "./webp": { + "import": "./webp.js", + "require": "./cjs/webp.js", + "types": "./webp.d.ts" + }, + "./websocket": { + "import": "./websocket.js", + "require": "./cjs/websocket.js", + "types": "./websocket.d.ts" + }, + "./withContent": { + "import": "./withContent.js", + "require": "./cjs/withContent.js", + "types": "./withContent.d.ts" + }, + "./withCookies": { + "import": "./withCookies.js", + "require": "./cjs/withCookies.js", + "types": "./withCookies.d.ts" + }, + "./withParams": { + "import": "./withParams.js", + "require": "./cjs/withParams.js", + "types": "./withParams.d.ts" + } + }, "keywords": [ "api", "router", @@ -30,7 +109,7 @@ "prerelease": "yarn verify", "prebuild": "rimraf dist && mkdir dist && yarn coverage && yarn format", "build": "rollup -c", - "release": "release --tag --push --patch --src=dist", + "release": "release --tag --push --type=next --src=dist", "runtime:bun": "bun example/bun.ts", "runtime:node": "node example/node.js" }, diff --git a/rollup.config.mjs b/rollup.config.mjs index 52a6c841..d3b0de94 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -5,34 +5,40 @@ import bundleSize from 'rollup-plugin-bundle-size' import copy from 'rollup-plugin-copy' export default async () => { - const files = await globby('./src/*.ts', { + const files = (await globby('./src/*.ts', { ignore: ['**/*.spec.ts', 'example'], - }) + })).map(path => ({ + path, + shortPath: path.replace(/(\/src)|(\.ts)/g, '').replace('./index', '.'), + esm: path.replace('/src/', '/dist/').replace('.ts', '.js'), + cjs: path.replace('/src/', '/dist/cjs/').replace('.ts', '.js'), + types: path.replace('/src/', '/dist/').replace('.ts', '.d.ts'), + })) - console.log({ files }) + console.log(files.map(f => f.path)) - return files.map((path) => ({ - input: path, + return files.map(file => ({ + input: file.path, output: [ { format: 'esm', - file: path.replace('/src/', '/dist/').replace('.ts', '.js'), - // sourcemap: true, + file: file.esm, + sourcemap: false, }, { format: 'cjs', - file: path.replace('/src/', '/dist/cjs/').replace('.ts', '.js'), - // sourcemap: true, + file: file.cjs, + sourcemap: false, }, ], plugins: [ - typescript({ sourceMap: false }), + typescript({ sourceMap: true }), terser(), bundleSize(), copy({ targets: [ { - src: ['CONTRIBUTING.md', 'CODE-OF-CONDUCT.md', 'LICENSE'], + src: ['LICENSE'], dest: 'dist', }, ],