Skip to content

Commit

Permalink
Align cjs/mjs packaging to esm first (#719)
Browse files Browse the repository at this point in the history
* chore(vscode): fix config

* chore(dev-deps): to latest

* chore: reduce size-limit in accordance with brotli

* ci: rework node 18 vs 20 to keep essential

* fix: reformat ncu.yml

* ci: codecov version update

* docs: regenerate api doc

* feat: align to esm first

* chore: remove references to jest

* docs: improve description

* chore: small improvements with links and comments

* ci: explicit test-examples

* docs: finalize doc
  • Loading branch information
belgattitude authored Nov 17, 2023
1 parent 2b4265b commit bae6ce0
Show file tree
Hide file tree
Showing 80 changed files with 877 additions and 2,449 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-geese-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@httpx/dsn-parser': minor
---

Move to esm first (dual cjs/mjs is till supported in the mid-term)
7 changes: 7 additions & 0 deletions .changeset/smooth-bats-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@httpx/dsn-parser': patch
'@httpx/exception': patch
'@httpx/json-api': patch
---

Upgrade tsup to 7.3 and build with esbuild 0.19.3
5 changes: 5 additions & 0 deletions .changeset/tough-pigs-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@httpx/json-api': minor
---

Move to esm first (dual esm/cjs) is still supported
5 changes: 5 additions & 0 deletions .changeset/wicked-kiwis-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@httpx/dsn-parser': minor
---

Restore node 16 official support / ES2021 (was working anyway)
2 changes: 1 addition & 1 deletion .github/scripts/install-codecov.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION=0.6.1
VERSION=0.7.1
PLATFORM=linux
CODECOV_BINARY_URL=https://github.com/codecov/uploader/releases/download/v${VERSION}/codecov-${PLATFORM}
OUTPUT_DIR="$(cd $(dirname $0); pwd)/download"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:
contents: read

jobs:
test:
test-examples:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-monorepo-integrity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ permissions:
contents: read

jobs:
test:
install-integrity:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
steps:
- uses: actions/checkout@v4

Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/ci-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [20.x]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -50,15 +50,13 @@ jobs:
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run typecheck

- name: 🔬 ESLint checks
if: matrix.node-version == '18.x'
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run lint

- name: 🧪 Unit tests
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run test-unit --coverage

- name: ☂️ Codecov upload
working-directory: ${{ github.workspace }}
if: matrix.node-version == '18.x'
run: |
bash .github/scripts/install-codecov.sh
yarn g:ci-coverage-upload
Expand All @@ -68,17 +66,13 @@ jobs:
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run build

- name: 📐 Check build for size-limits
if: matrix.node-version == '18.x'
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run check-size

- name: 🛟 Check build for ecmascript compliance
if: matrix.node-version == '18.x'
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run check-dist

- name: 🛟 Check publishable dist (publint)
if: matrix.node-version == '18.x'
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run check-pub

- name: 📄 Check doc can be built
if: matrix.node-version == '18.x'
run: yarn workspaces foreach -tv --worktree --from 'packages/*' --no-private run build-doc
4 changes: 2 additions & 2 deletions .github/workflows/release-or-version-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
# @link https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
fetch-depth: 0

- name: Use Node.js 18.x
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x

- name: 📥 Monorepo install
uses: ./.github/actions/yarn-nm-install
Expand Down
2 changes: 1 addition & 1 deletion .ncurc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

# Add here exclusions on packages if any
reject: [
]
]
22 changes: 11 additions & 11 deletions examples/nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
},
"dependencies": {
"@httpx/exception": "workspace:^",
"axios": "1.6.0",
"ky": "1.1.1",
"next": "14.0.0",
"pino": "8.16.1",
"axios": "1.6.2",
"ky": "1.1.3",
"next": "14.0.3",
"pino": "8.16.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"superjson": "2.2.0",
"superjson": "2.2.1",
"zod": "3.22.4"
},
"devDependencies": {
"@belgattitude/eslint-config-bases": "3.1.0",
"@types/node": "20.8.9",
"@types/react": "18.2.33",
"@types/react-dom": "18.2.14",
"@belgattitude/eslint-config-bases": "3.5.0",
"@types/node": "20.9.1",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"cross-env": "7.0.3",
"eslint": "8.52.0",
"eslint-config-next": "14.0.0",
"eslint": "8.53.0",
"eslint-config-next": "14.0.3",
"postcss": "8.4.31",
"rimraf": "5.0.5",
"tailwindcss": "3.3.5",
Expand Down
2 changes: 1 addition & 1 deletion monorepo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"name": "📦 @httpx/json-api",
"path": "packages/dsn-parser"
"path": "packages/json-api"
},
{
"name": "📦 @httpx/exception",
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
},
"homepage": "https://github.com/belgattitude/httpx",
"repository": "belgattitude/httpx",
"resolutions?": {
"vite": "https://github.com/vitest-dev/vitest/issues/4112"
},
"resolutions": {
"vite": "^5.0.0"
},
"scripts": {
"g:clean": "yarn clean:global-cache && yarn workspaces foreach --all -pv run clean",
"g:build": "yarn workspaces foreach --all -tv run build",
Expand Down
10 changes: 6 additions & 4 deletions packages/dsn-parser/.size-limit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
*/
module.exports = [
{
name: 'JS (ESM)',
name: 'Everything (ESM)',
path: ['dist/index.mjs'],
limit: '1.20KB',
import: "*",
limit: '1.10KB',
},
{
name: 'JS (CJS)',
name: 'Everything (CJS)',
import: "*",
path: ['dist/index.cjs'],
limit: '1.20KB',
limit: '1.40KB',
},
];
36 changes: 19 additions & 17 deletions packages/dsn-parser/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# @httpx/dsn-parser

DSN parser, validation utilities, and query string helper in a light and modern package.

[![npm](https://img.shields.io/npm/v/@httpx/dsn-parser?style=for-the-badge&labelColor=222)](https://www.npmjs.com/package/@httpx/dsn-parser)
[![codecov](https://img.shields.io/codecov/c/github/belgattitude/httpx?label=unit&logo=codecov&flag=httpx-dsn-parser-unit&style=for-the-badge&labelColor=000000)](https://codecov.io/gh/belgattitude/httpx)
[![size](https://img.shields.io/bundlephobia/minzip/@httpx/dsn-parser@latest?label=Max&style=for-the-badge&labelColor=333&color=informational)](https://bundlephobia.com/package/@httpx/dsn-parser@latest)
![bundles](https://img.shields.io/static/v1?label=&message=cjs|esm|treeshake&logo=webpack&style=for-the-badge&labelColor=444&color=informational)
![node](https://img.shields.io/static/v1?label=Node&message=16%2b&logo=node.js&style=for-the-badge&labelColor=444&color=informational)
[![browserslist](https://img.shields.io/static/v1?label=Browser&message=modern&logo=googlechrome&style=for-the-badge&labelColor=444&color=informational)](https://browserslist.dev/?q=ZGVmYXVsdHMgYW5kIHN1cHBvcnRzIGVzNi1tb2R1bGUsIG5vdCBkZWFkLCBub3Qgb3BfbWluaSBhbGwsIG5vZGUgMTY%3D)
![types](https://img.shields.io/static/v1?label=typings&message=4.5%2B&logo=typescript&style=for-the-badge&labelColor=000000&color=9cf)
[![npm](https://img.shields.io/npm/dm/@httpx/dsn-parser?style=for-the-badge&labelColor=000000)](https://www.npmjs.com/package/@httpx/dsn-parser)
[![license](https://img.shields.io/npm/l/@httpx/dsn-parser?style=for-the-badge&labelColor=000000)](https://github.com/belgattitude/httpx/blob/main/LICENSE)
DSN & JDBC string parser with query params support in a light and modern package.

[![npm](https://img.shields.io/npm/v/@httpx/dsn-parser?style=for-the-badge&label=Npm&labelColor=444&color=informational)](https://www.npmjs.com/package/@httpx/dsn-parser)
[![changelog](https://img.shields.io/static/v1?label=&message=changelog&logo=keep-a-changelog&style=for-the-badge&labelColor=444&color=informational)](https://github.com/belgattitude/httpx/blob/main/packages/dsn-parser/CHANGELOG.md)
[![codecov](https://img.shields.io/codecov/c/github/belgattitude/httpx?logo=codecov&label=Coverage&flag=httpx-exception-unit&style=for-the-badge&labelColor=444)](https://app.codecov.io/gh/belgattitude/httpx/tree/main/packages%2Fdsn-parser)
[![bundles](https://img.shields.io/static/v1?label=&message=cjs|esm@treeshake&logo=webpack&style=for-the-badge&labelColor=444&color=informational)](https://github.com/belgattitude/httpx/blob/main/packages/dsn-parser/.size-limit.cjs)
![node](https://img.shields.io/static/v1?label=Node&message=18%2b&logo=node.js&style=for-the-badge&labelColor=444&color=informational)
[![browserslist](https://img.shields.io/static/v1?label=Browser&message=modern&logo=googlechrome&style=for-the-badge&labelColor=444&color=informational)](https://browserslist.dev/?q=ZGVmYXVsdHM%3D)
[![size](https://img.shields.io/bundlephobia/minzip/@httpx/dsn-parser@latest?label=Max&style=for-the-badge&labelColor=444&color=informational)](https://bundlephobia.com/package/@httpx/dsn-parser@latest)
[![maintainability](https://img.shields.io/codeclimate/maintainability/belgattitude/httpx?label=Quality&logo=code-climate&style=for-the-badge&labelColor=444)](https://codeclimate.com/github/belgattitude/httpx)
[![downloads](https://img.shields.io/npm/dm/@httpx/dsn-parser?style=for-the-badge&labelColor=444)](https://www.npmjs.com/package/@httpx/dsn-parser)
[![license](https://img.shields.io/npm/l/@httpx/dsn-parser?style=for-the-badge&labelColor=444)](https://github.com/belgattitude/httpx/blob/main/LICENSE)

## Install

Expand All @@ -22,12 +23,13 @@ $ pnpm add @httpx/dsn-parser

## Features

- [x] Parse individual fields (ie: `driver`, `user`, `password`, `host`...)
- [x] Handle query string with casting of boolean and numeric values.
- [x] Handle [special characters like](#why--in-password-matters) `/`, `:`... in the password (some libs won't).
- [x] Error with indicative message / reasons (discriminative union or throwing).
- [x] Don't leak passwords in the error message.
- [x] Assertion and typeguard helpers (ie: [easy integrate with zod](#zod-integration-example)).
- 🚀  Parse individual fields (ie: `driver`, `user`, `password`, `host`...)
- ✨‍  Handle query string parameters and converts to boolean and numeric values.
- 🦄  Handle [special characters like](#why--in-password-matters) `/`, `:`... in the password (some libs won't).
- 🧐  Error with indicative message / reasons (discriminative union or throwing).
- 🛡️  Don't leak passwords in the error message.
- ⚒️  Assertion and typeguard helpers
- 🤗  Ecosystem friendly (ie: [easy integrate with zod](#zod-integration-example)).

## Quick start

Expand Down
34 changes: 17 additions & 17 deletions packages/dsn-parser/docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

#### Type declaration

| Name | Type | Description |
| :----------------- | :------------------------------------------------------------------ | :--------------------------------------------------------- |
| `lowercaseDriver?` | `boolean` | Whether to lowercase parsed driver name, default: false |
| `overrides?` | `Omit`<`Partial`<[`ParsedDsn`](README.md#parseddsn)\>, `"params"`\> | Overrides parsed values by those one (except query params) |
| Name | Type | Description |
| :----------------- | :-------------------------------------------------------------------- | :--------------------------------------------------------- |
| `lowercaseDriver?` | `boolean` | Whether to lowercase parsed driver name, default: false |
| `overrides?` | `Omit`\<`Partial`\<[`ParsedDsn`](README.md#parseddsn)\>, `"params"`\> | Overrides parsed values by those one (except query params) |

---

Expand All @@ -45,15 +45,15 @@

#### Type declaration

| Name | Type | Description |
| :-------- | :----------------------------------------------------- | :----------- |
| `db?` | `string` | - |
| `driver` | `string` | - |
| `host` | `string` | - |
| `params?` | `Record`<`string`, `boolean` \| `number` \| `string`\> | Query params |
| `pass?` | `string` | - |
| `port?` | `number` | - |
| `user?` | `string` | - |
| Name | Type | Description |
| :-------- | :------------------------------------------------------ | :----------- |
| `db?` | `string` | - |
| `driver` | `string` | - |
| `host` | `string` | - |
| `params?` | `Record`\<`string`, `boolean` \| `number` \| `string`\> | Query params |
| `pass?` | `string` | - |
| `port?` | `number` | - |
| `user?` | `string` | - |

## Functions

Expand Down Expand Up @@ -133,10 +133,10 @@ dsn is string

#### Parameters

| Name | Type |
| :--------- | :------------------------------------------------------------------------------- |
| `dsn` | `unknown` |
| `options?` | [`ParseDsnOptions`](README.md#parsedsnoptions) & { `errorMsgPrefix?`: `string` } |
| Name | Type |
| :--------- | :-------------------------------------------------------------------------------- |
| `dsn` | `unknown` |
| `options?` | [`ParseDsnOptions`](README.md#parsedsnoptions) & \{ `errorMsgPrefix?`: `string` } |

#### Returns

Expand Down
Loading

0 comments on commit bae6ce0

Please sign in to comment.