Skip to content

Commit

Permalink
Use ts-bridge as build tool, set moduleResolution to NodeNext (#18
Browse files Browse the repository at this point in the history
)

## Explanation

As part of our OKR for upgrading TypeScript to v5.0+ (Q2 2024 O3KR4), we
are updating our core dependencies to generate builds and type
declarations for both CJS and ESM.

## References

- Same update made to `@metamask/utils`:
MetaMask/utils#182
- Required to update core repo's `moduleResolution` setting to
`NodeNext`:
  - Blocks: MetaMask/core#3651
 
## Changelog

### Added

- Newly exports the following types: `AnyStruct`, `EnumSchema`,
`InferStructTuple`, `IsExactMatch`, `IsMatch`, `IsRecord`, `IsTuple`,
`ObjectSchema`, `OmitBy`, `Optionalize`, `PickBy`, `Simplify`,
`UnionToIntersection`.
  • Loading branch information
MajorLift authored May 29, 2024
1 parent 7d8a2e1 commit 1c1e0a9
Show file tree
Hide file tree
Showing 8 changed files with 864 additions and 1,067 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Newly exports the following types: `AnyStruct`, `EnumSchema`, `InferStructTuple`, `IsExactMatch`, `IsMatch`, `IsRecord`, `IsTuple`, `ObjectSchema`, `OmitBy`, `Optionalize`, `PickBy`, `Simplify`, `UnionToIntersection`.

## [2.0.0]

### Changed
Expand Down
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,26 @@
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/types/index.d.ts"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.cts",
"files": [
"dist"
],
"scripts": {
"build": "tsup --clean && yarn build:types",
"build": "ts-bridge --project tsconfig.build.json --clean",
"build:docs": "typedoc",
"build:types": "tsc --project tsconfig.build.json",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:dependencies --check && yarn lint:changelog",
"lint:changelog": "auto-changelog validate --prettier",
"lint:dependencies": "depcheck && yarn dedupe",
Expand All @@ -78,9 +82,10 @@
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@ts-bridge/cli": "^0.1.2",
"@ts-bridge/shims": "^0.1.1",
"@types/expect": "^24.3.0",
"@types/lodash": "^4.14.144",
"@types/lodash-es": "^4.17.12",
"@types/node": "^18.7.14",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
Expand All @@ -97,10 +102,9 @@
"is-url": "^1.2.4",
"is-uuid": "^1.0.2",
"jest": "^29.7.0",
"lodash-es": "^4.17.21",
"lodash": "^4.17.21",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.3.0",
"tsup": "patch:tsup@npm%3A8.0.2#~/.yarn/patches/tsup-npm-8.0.2-86e40f68a7.patch",
"typedoc": "^0.25.9",
"typescript": "~4.8.4",
"vitest": "^1.2.2"
Expand All @@ -115,8 +119,7 @@
},
"lavamoat": {
"allowScripts": {
"vitest>vite>esbuild": true,
"tsup>esbuild": true
"vitest>vite>esbuild": true
}
}
}
16 changes: 15 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ export * from './structs/coercions.js';
export * from './structs/refinements.js';
export * from './structs/types.js';
export * from './structs/utilities.js';
export type { ObjectSchema, Optionalize, Simplify } from './utils.js';
export type {
AnyStruct,
EnumSchema,
InferStructTuple,
IsExactMatch,
IsMatch,
IsRecord,
IsTuple,
ObjectSchema,
OmitBy,
Optionalize,
PickBy,
Simplify,
UnionToIntersection,
} from './utils.js';
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line n/no-unsupported-features/node-builtins
import assert, { CallTracker } from 'assert';
import fs from 'fs';
import { pick } from 'lodash-es';
import { pick } from 'lodash';
import { basename, extname, resolve } from 'path';
import { describe, it } from 'vitest';

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"emitDeclarationOnly": true,
"inlineSources": true,
"noEmit": false,
"outDir": "dist/types",
"outDir": "dist",
"rootDir": "src",
"sourceMap": true
},
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2020"],
"module": "CommonJS",
"moduleResolution": "node",
"noEmit": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
Expand Down
35 changes: 0 additions & 35 deletions tsup.config.ts

This file was deleted.

Loading

0 comments on commit 1c1e0a9

Please sign in to comment.