diff --git a/build.config.ts b/build.config.ts new file mode 100644 index 0000000..6a180ba --- /dev/null +++ b/build.config.ts @@ -0,0 +1,10 @@ +import { rm } from "node:fs/promises"; +import { defineBuildConfig } from "unbuild"; + +export default defineBuildConfig({ + hooks: { + async "build:done"() { + await rm("dist/index.d.ts"); + }, + }, +}); diff --git a/package.json b/package.json index aec4ec6..ba20db4 100644 --- a/package.json +++ b/package.json @@ -7,15 +7,13 @@ "sideEffects": false, "exports": { ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", - "import": "./dist/index.mjs" + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" }, "./*": "./*" }, - "main": "./dist/index.cjs", "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", + "types": "./dist/index.d.mts", "files": [ "dist" ], diff --git a/src/encoding.ts b/src/encoding.ts index 0708453..3d85024 100644 --- a/src/encoding.ts +++ b/src/encoding.ts @@ -47,6 +47,15 @@ export function encodeHash(text: string): string { .replace(ENC_CARET_RE, "^"); } +/** + * Encodes hostname with punycode encoding. + * + * @group encoding_utils + */ +export function encodeHost(name = "") { + return toASCII(name); +} + /** * Encodes characters that need to be encoded for query values in the query * section of the URL. @@ -165,12 +174,3 @@ export function decodeQueryKey(text: string): string { export function decodeQueryValue(text: string): string { return decode(text.replace(PLUS_RE, " ")); } - -/** - * Encodes hostname with punycode encoding. - * - * @group encoding_utils - */ -export function encodeHost(name = "") { - return toASCII(name); -} diff --git a/src/index.ts b/src/index.ts index ede636a..c0cd3fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,65 @@ -export * from "./encoding"; -export * from "./parse"; -export * from "./query"; -export * from "./url"; -export * from "./utils"; +export { + encode, + encodeHash, + encodeHost, + encodeQueryValue, + encodeQueryKey, + encodePath, + encodeParam, + decode, + decodePath, + decodeQueryKey, + decodeQueryValue, +} from "./encoding"; + +export type { ParsedURL, ParsedAuth, ParsedHost } from "./parse"; + +export { + parseURL, + parsePath, + parseAuth, + parseHost, + stringifyParsedURL, + parseFilename, +} from "./parse"; + +export type { QueryValue, QueryObject, ParsedQuery } from "./query"; + +export { parseQuery, encodeQueryItem, stringifyQuery } from "./query"; + +export { $URL, createURL } from "./url"; + +export type { HasProtocolOptions } from "./utils"; + +export { + isRelative, + hasProtocol, + isScriptProtocol, + hasTrailingSlash, + withoutTrailingSlash, + withTrailingSlash, + hasLeadingSlash, + withoutLeadingSlash, + withLeadingSlash, + cleanDoubleSlashes, + withBase, + withoutBase, + withQuery, + filterQuery, + getQuery, + isEmptyURL, + isNonEmptyURL, + joinURL, + joinRelativeURL, + withHttp, + withHttps, + withoutProtocol, + withProtocol, + normalizeURL, + resolveURL, + isSamePath, + isEqual, + withFragment, + withoutFragment, + withoutHost, +} from "./utils"; diff --git a/tsconfig.json b/tsconfig.json index 7ed9c46..7ffe20b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,9 +3,8 @@ "target": "ESNext", "module": "ESNext", "moduleResolution": "Node", - "esModuleInterop": true + "esModuleInterop": true, + "strict": true, }, - "include": [ - "src" - ] + "include": ["src"] }