From fe34a340a048ae4d286d766e533a8ba4f9387c4e Mon Sep 17 00:00:00 2001 From: Kevin Whitley Date: Wed, 14 Jun 2023 16:51:18 -0500 Subject: [PATCH 1/6] tempting fate with an export shakeup --- package.json | 69 ++++++++++++++++++++++++++++++++++++++++++++--- rollup.config.mjs | 11 +------- 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 1e774116..821a95ad 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,72 @@ { "name": "itty-router", - "version": "4.0.9", + "version": "4.0.10", "description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.", "type": "module", - "main": "./index.js", + "main": "./dist/index.cjs.js", + "module": "./dist/index.js", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs.js" + }, + "./createCors": { + "import": "./dist/createCors.js", + "require": "./dist/createCors.cjs.js" + }, + "./createResponse": { + "import": "./dist/createResponse.js", + "require": "./dist/createResponse.cjs.js" + }, + "./error": { + "import": "./dist/error.js", + "require": "./dist/error.cjs.js" + }, + "./html": { + "import": "./dist/html.js", + "require": "./dist/html.cjs.js" + }, + "./jpeg": { + "import": "./dist/jpeg.js", + "require": "./dist/jpeg.cjs.js" + }, + "./png": { + "import": "./dist/png.js", + "require": "./dist/png.cjs.js" + }, + "./Router": { + "import": "./dist/Router.js", + "require": "./dist/Router.cjs.js" + }, + "./status": { + "import": "./dist/status.js", + "require": "./dist/status.cjs.js" + }, + "./text": { + "import": "./dist/text.js", + "require": "./dist/text.cjs.js" + }, + "./webp": { + "import": "./dist/webp.js", + "require": "./dist/webp.cjs.js" + }, + "./websocket": { + "import": "./dist/websocket.js", + "require": "./dist/websocket.cjs.js" + }, + "./withContent": { + "import": "./dist/withContent.js", + "require": "./dist/withContent.cjs.js" + }, + "./withCookies": { + "import": "./dist/withCookies.js", + "require": "./dist/withCookies.cjs.js" + }, + "./withParams": { + "import": "./dist/withParams.js", + "require": "./dist/withParams.cjs.js" + } + }, "keywords": [ "api", "router", @@ -30,7 +93,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", "runtime:bun": "bun example/bun.ts", "runtime:node": "node example/node.js" }, diff --git a/rollup.config.mjs b/rollup.config.mjs index 52a6c841..84871d18 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -2,7 +2,6 @@ import terser from '@rollup/plugin-terser' import typescript from '@rollup/plugin-typescript' import { globby } from 'globby' import bundleSize from 'rollup-plugin-bundle-size' -import copy from 'rollup-plugin-copy' export default async () => { const files = await globby('./src/*.ts', { @@ -21,7 +20,7 @@ export default async () => { }, { format: 'cjs', - file: path.replace('/src/', '/dist/cjs/').replace('.ts', '.js'), + file: path.replace('/src/', '/dist/').replace('.ts', '.cjs.js'), // sourcemap: true, }, ], @@ -29,14 +28,6 @@ export default async () => { typescript({ sourceMap: false }), terser(), bundleSize(), - copy({ - targets: [ - { - src: ['CONTRIBUTING.md', 'CODE-OF-CONDUCT.md', 'LICENSE'], - dest: 'dist', - }, - ], - }), ], })) } From 4b904ef738cfd593b56e0473ee5f6d819d96bde9 Mon Sep 17 00:00:00 2001 From: Kevin Whitley Date: Wed, 14 Jun 2023 16:55:49 -0500 Subject: [PATCH 2/6] released v4.0.10-next.0 - testing exports --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 821a95ad..c55902a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "itty-router", - "version": "4.0.10", + "version": "4.0.10-next.0", "description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.", "type": "module", "main": "./dist/index.cjs.js", From 6bfb32cab209c8a790f12dc49a5b7d64fd9c18a8 Mon Sep 17 00:00:00 2001 From: Kevin Whitley Date: Wed, 14 Jun 2023 17:29:21 -0500 Subject: [PATCH 3/6] released v4.0.10-next.1 - included types in exports --- package.json | 57 ++++++++++++++++++++++++++++++++--------------- rollup.config.mjs | 36 ++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index c55902a4..c3f02900 100644 --- a/package.json +++ b/package.json @@ -1,72 +1,93 @@ { "name": "itty-router", - "version": "4.0.10-next.0", + "version": "4.0.10-next.1", "description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.", "type": "module", - "main": "./dist/index.cjs.js", - "module": "./dist/index.js", + "main": "dist/index.cjs.js", + "module": "dist/index.js", + "types": "dist/index.d.ts", "exports": { ".": { "import": "./dist/index.js", - "require": "./dist/index.cjs.js" + "require": "./dist/index.cjs.js", + "types": "./dist/index.d.ts" }, "./createCors": { "import": "./dist/createCors.js", - "require": "./dist/createCors.cjs.js" + "require": "./dist/createCors.cjs.js", + "types": "./dist/createCors.d.ts" }, "./createResponse": { "import": "./dist/createResponse.js", - "require": "./dist/createResponse.cjs.js" + "require": "./dist/createResponse.cjs.js", + "types": "./dist/createResponse.d.ts" }, "./error": { "import": "./dist/error.js", - "require": "./dist/error.cjs.js" + "require": "./dist/error.cjs.js", + "types": "./dist/error.d.ts" }, "./html": { "import": "./dist/html.js", - "require": "./dist/html.cjs.js" + "require": "./dist/html.cjs.js", + "types": "./dist/html.d.ts" }, "./jpeg": { "import": "./dist/jpeg.js", - "require": "./dist/jpeg.cjs.js" + "require": "./dist/jpeg.cjs.js", + "types": "./dist/jpeg.d.ts" }, "./png": { "import": "./dist/png.js", - "require": "./dist/png.cjs.js" + "require": "./dist/png.cjs.js", + "types": "./dist/png.d.ts" }, "./Router": { "import": "./dist/Router.js", - "require": "./dist/Router.cjs.js" + "require": "./dist/Router.cjs.js", + "types": "./dist/Router.d.ts" }, "./status": { "import": "./dist/status.js", - "require": "./dist/status.cjs.js" + "require": "./dist/status.cjs.js", + "types": "./dist/status.d.ts" }, "./text": { "import": "./dist/text.js", - "require": "./dist/text.cjs.js" + "require": "./dist/text.cjs.js", + "types": "./dist/text.d.ts" }, "./webp": { "import": "./dist/webp.js", - "require": "./dist/webp.cjs.js" + "require": "./dist/webp.cjs.js", + "types": "./dist/webp.d.ts" }, "./websocket": { "import": "./dist/websocket.js", - "require": "./dist/websocket.cjs.js" + "require": "./dist/websocket.cjs.js", + "types": "./dist/websocket.d.ts" }, "./withContent": { "import": "./dist/withContent.js", - "require": "./dist/withContent.cjs.js" + "require": "./dist/withContent.cjs.js", + "types": "./dist/withContent.d.ts" }, "./withCookies": { "import": "./dist/withCookies.js", - "require": "./dist/withCookies.cjs.js" + "require": "./dist/withCookies.cjs.js", + "types": "./dist/withCookies.d.ts" }, "./withParams": { "import": "./dist/withParams.js", - "require": "./dist/withParams.cjs.js" + "require": "./dist/withParams.cjs.js", + "types": "./dist/withParams.d.ts" } }, + "files": [ + "dist", + "README.md", + "LICENSE" + ], "keywords": [ "api", "router", diff --git a/rollup.config.mjs b/rollup.config.mjs index 84871d18..bab66421 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -2,25 +2,39 @@ import terser from '@rollup/plugin-terser' import typescript from '@rollup/plugin-typescript' import { globby } from 'globby' 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/').replace('.ts', '.cjs.js'), + types: path.replace('/src/', '/dist/').replace('.ts', '.d.ts'), + })) + + console.log(files.map(f => f.path)) - console.log({ files }) + // const exportInjection = files.map(({ shortPath, esm, cjs, types }) => ` + // "${shortPath}": { + // "import": "${esm}", + // "require": "${cjs}", + // "types": "${types}", + // }`).join(',\n') - return files.map((path) => ({ - input: path, + return files.map(file => ({ + input: file.path, output: [ { format: 'esm', - file: path.replace('/src/', '/dist/').replace('.ts', '.js'), + file: file.esm, // sourcemap: true, }, { format: 'cjs', - file: path.replace('/src/', '/dist/').replace('.ts', '.cjs.js'), + file: file.cjs, // sourcemap: true, }, ], @@ -28,6 +42,14 @@ export default async () => { typescript({ sourceMap: false }), terser(), bundleSize(), + copy({ + targets: [ + { + src: ['LICENSE'], + dest: 'dist', + }, + ], + }), ], })) } From d24bb16abc371356c0a69ac326231742373d0248 Mon Sep 17 00:00:00 2001 From: Kevin Whitley Date: Wed, 14 Jun 2023 17:51:30 -0500 Subject: [PATCH 4/6] cleaned up rollup config --- rollup.config.mjs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index bab66421..42ab91ff 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -17,29 +17,22 @@ export default async () => { console.log(files.map(f => f.path)) - // const exportInjection = files.map(({ shortPath, esm, cjs, types }) => ` - // "${shortPath}": { - // "import": "${esm}", - // "require": "${cjs}", - // "types": "${types}", - // }`).join(',\n') - return files.map(file => ({ input: file.path, output: [ { format: 'esm', file: file.esm, - // sourcemap: true, + sourcemap: false, }, { format: 'cjs', file: file.cjs, - // sourcemap: true, + sourcemap: false, }, ], plugins: [ - typescript({ sourceMap: false }), + typescript({ sourceMap: true }), terser(), bundleSize(), copy({ From 2248f2d1ab9a90efeacdcb81deabfa518814e43e Mon Sep 17 00:00:00 2001 From: Kevin Whitley Date: Wed, 14 Jun 2023 17:56:00 -0500 Subject: [PATCH 5/6] released v4.0.10-next.2 - verifying cjs import works with or without cjs/ prefix --- package.json | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c3f02900..593ad889 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "itty-router", - "version": "4.0.10-next.1", + "version": "4.0.10-next.2", "description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.", "type": "module", "main": "dist/index.cjs.js", @@ -81,6 +81,66 @@ "import": "./dist/withParams.js", "require": "./dist/withParams.cjs.js", "types": "./dist/withParams.d.ts" + }, + "./cjs": { + "require": "./dist/index.cjs.js", + "types": "./dist/index.d.ts" + }, + "./cjs/createCors": { + "require": "./dist/createCors.cjs.js", + "types": "./dist/createCors.d.ts" + }, + "./cjs/createResponse": { + "require": "./dist/createResponse.cjs.js", + "types": "./dist/createResponse.d.ts" + }, + "./cjs/error": { + "require": "./dist/error.cjs.js", + "types": "./dist/error.d.ts" + }, + "./cjs/html": { + "require": "./dist/html.cjs.js", + "types": "./dist/html.d.ts" + }, + "./cjs/jpeg": { + "require": "./dist/jpeg.cjs.js", + "types": "./dist/jpeg.d.ts" + }, + "./cjs/png": { + "require": "./dist/png.cjs.js", + "types": "./dist/png.d.ts" + }, + "./cjs/Router": { + "require": "./dist/Router.cjs.js", + "types": "./dist/Router.d.ts" + }, + "./cjs/status": { + "require": "./dist/status.cjs.js", + "types": "./dist/status.d.ts" + }, + "./cjs/text": { + "require": "./dist/text.cjs.js", + "types": "./dist/text.d.ts" + }, + "./cjs/webp": { + "require": "./dist/webp.cjs.js", + "types": "./dist/webp.d.ts" + }, + "./cjs/websocket": { + "require": "./dist/websocket.cjs.js", + "types": "./dist/websocket.d.ts" + }, + "./cjs/withContent": { + "require": "./dist/withContent.cjs.js", + "types": "./dist/withContent.d.ts" + }, + "./cjs/withCookies": { + "require": "./dist/withCookies.cjs.js", + "types": "./dist/withCookies.d.ts" + }, + "./cjs/withParams": { + "require": "./dist/withParams.cjs.js", + "types": "./dist/withParams.d.ts" } }, "files": [ From ac9b3d4cdb43da7b038b9de13a6162d27748662c Mon Sep 17 00:00:00 2001 From: Kevin Whitley Date: Wed, 14 Jun 2023 18:00:44 -0500 Subject: [PATCH 6/6] released v4.0.10-next.3 - moving release source to dist --- package.json | 165 ++++++++++++++-------------------------------- rollup.config.mjs | 2 +- 2 files changed, 51 insertions(+), 116 deletions(-) diff --git a/package.json b/package.json index 593ad889..0b5c8a1b 100644 --- a/package.json +++ b/package.json @@ -1,153 +1,88 @@ { "name": "itty-router", - "version": "4.0.10-next.2", + "version": "4.0.10-next.3", "description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.", "type": "module", - "main": "dist/index.cjs.js", - "module": "dist/index.js", - "types": "dist/index.d.ts", + "main": "index.js", + "module": "index.js", + "types": "index.d.ts", "exports": { ".": { - "import": "./dist/index.js", - "require": "./dist/index.cjs.js", - "types": "./dist/index.d.ts" + "import": "./index.js", + "require": "./cjs/index.js", + "types": "./index.d.ts" }, "./createCors": { - "import": "./dist/createCors.js", - "require": "./dist/createCors.cjs.js", - "types": "./dist/createCors.d.ts" + "import": "./createCors.js", + "require": "./cjs/createCors.js", + "types": "./createCors.d.ts" }, "./createResponse": { - "import": "./dist/createResponse.js", - "require": "./dist/createResponse.cjs.js", - "types": "./dist/createResponse.d.ts" + "import": "./createResponse.js", + "require": "./cjs/createResponse.js", + "types": "./createResponse.d.ts" }, "./error": { - "import": "./dist/error.js", - "require": "./dist/error.cjs.js", - "types": "./dist/error.d.ts" + "import": "./error.js", + "require": "./cjs/error.js", + "types": "./error.d.ts" }, "./html": { - "import": "./dist/html.js", - "require": "./dist/html.cjs.js", - "types": "./dist/html.d.ts" + "import": "./html.js", + "require": "./cjs/html.js", + "types": "./html.d.ts" }, "./jpeg": { - "import": "./dist/jpeg.js", - "require": "./dist/jpeg.cjs.js", - "types": "./dist/jpeg.d.ts" + "import": "./jpeg.js", + "require": "./cjs/jpeg.js", + "types": "./jpeg.d.ts" }, "./png": { - "import": "./dist/png.js", - "require": "./dist/png.cjs.js", - "types": "./dist/png.d.ts" + "import": "./png.js", + "require": "./cjs/png.js", + "types": "./png.d.ts" }, "./Router": { - "import": "./dist/Router.js", - "require": "./dist/Router.cjs.js", - "types": "./dist/Router.d.ts" + "import": "./Router.js", + "require": "./cjs/Router.js", + "types": "./Router.d.ts" }, "./status": { - "import": "./dist/status.js", - "require": "./dist/status.cjs.js", - "types": "./dist/status.d.ts" + "import": "./status.js", + "require": "./cjs/status.js", + "types": "./status.d.ts" }, "./text": { - "import": "./dist/text.js", - "require": "./dist/text.cjs.js", - "types": "./dist/text.d.ts" + "import": "./text.js", + "require": "./cjs/text.js", + "types": "./text.d.ts" }, "./webp": { - "import": "./dist/webp.js", - "require": "./dist/webp.cjs.js", - "types": "./dist/webp.d.ts" + "import": "./webp.js", + "require": "./cjs/webp.js", + "types": "./webp.d.ts" }, "./websocket": { - "import": "./dist/websocket.js", - "require": "./dist/websocket.cjs.js", - "types": "./dist/websocket.d.ts" + "import": "./websocket.js", + "require": "./cjs/websocket.js", + "types": "./websocket.d.ts" }, "./withContent": { - "import": "./dist/withContent.js", - "require": "./dist/withContent.cjs.js", - "types": "./dist/withContent.d.ts" + "import": "./withContent.js", + "require": "./cjs/withContent.js", + "types": "./withContent.d.ts" }, "./withCookies": { - "import": "./dist/withCookies.js", - "require": "./dist/withCookies.cjs.js", - "types": "./dist/withCookies.d.ts" + "import": "./withCookies.js", + "require": "./cjs/withCookies.js", + "types": "./withCookies.d.ts" }, "./withParams": { - "import": "./dist/withParams.js", - "require": "./dist/withParams.cjs.js", - "types": "./dist/withParams.d.ts" - }, - "./cjs": { - "require": "./dist/index.cjs.js", - "types": "./dist/index.d.ts" - }, - "./cjs/createCors": { - "require": "./dist/createCors.cjs.js", - "types": "./dist/createCors.d.ts" - }, - "./cjs/createResponse": { - "require": "./dist/createResponse.cjs.js", - "types": "./dist/createResponse.d.ts" - }, - "./cjs/error": { - "require": "./dist/error.cjs.js", - "types": "./dist/error.d.ts" - }, - "./cjs/html": { - "require": "./dist/html.cjs.js", - "types": "./dist/html.d.ts" - }, - "./cjs/jpeg": { - "require": "./dist/jpeg.cjs.js", - "types": "./dist/jpeg.d.ts" - }, - "./cjs/png": { - "require": "./dist/png.cjs.js", - "types": "./dist/png.d.ts" - }, - "./cjs/Router": { - "require": "./dist/Router.cjs.js", - "types": "./dist/Router.d.ts" - }, - "./cjs/status": { - "require": "./dist/status.cjs.js", - "types": "./dist/status.d.ts" - }, - "./cjs/text": { - "require": "./dist/text.cjs.js", - "types": "./dist/text.d.ts" - }, - "./cjs/webp": { - "require": "./dist/webp.cjs.js", - "types": "./dist/webp.d.ts" - }, - "./cjs/websocket": { - "require": "./dist/websocket.cjs.js", - "types": "./dist/websocket.d.ts" - }, - "./cjs/withContent": { - "require": "./dist/withContent.cjs.js", - "types": "./dist/withContent.d.ts" - }, - "./cjs/withCookies": { - "require": "./dist/withCookies.cjs.js", - "types": "./dist/withCookies.d.ts" - }, - "./cjs/withParams": { - "require": "./dist/withParams.cjs.js", - "types": "./dist/withParams.d.ts" + "import": "./withParams.js", + "require": "./cjs/withParams.js", + "types": "./withParams.d.ts" } }, - "files": [ - "dist", - "README.md", - "LICENSE" - ], "keywords": [ "api", "router", @@ -174,7 +109,7 @@ "prerelease": "yarn verify", "prebuild": "rimraf dist && mkdir dist && yarn coverage && yarn format", "build": "rollup -c", - "release": "release --tag --push --type=next", + "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 42ab91ff..d3b0de94 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -11,7 +11,7 @@ export default async () => { path, shortPath: path.replace(/(\/src)|(\.ts)/g, '').replace('./index', '.'), esm: path.replace('/src/', '/dist/').replace('.ts', '.js'), - cjs: path.replace('/src/', '/dist/').replace('.ts', '.cjs.js'), + cjs: path.replace('/src/', '/dist/cjs/').replace('.ts', '.js'), types: path.replace('/src/', '/dist/').replace('.ts', '.d.ts'), }))