Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
chore(tools): add ts-patch, drop ttypescript
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed Oct 12, 2021
1 parent 5509114 commit 7c38efc
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@
"shelljs": "0.8.4",
"ts-jest": "27.0.5",
"ts-node": "10.2.1",
"ts-patch": "1.4.4",
"tsconfig-paths": "3.11.0",
"ttypescript": "1.5.12",
"typescript": "4.4.3",
"yargs": "17.2.1"
},
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async function build(): Promise<void> {
logger(argv, `remove stale ${format} directory`)

// Run build command
if (exec(`ttsc -p ${tsconfig}`, argv.dryRun) || argv.dryRun) {
if (exec(`tsc -p ${tsconfig}`, argv.dryRun) || argv.dryRun) {
// ! Add ESM-compatible export statement to `exports.default` statements
if (format === 'cjs') useDualExports([`./${format}/**`] as never[])
logger(argv, `build ${format}`)
Expand Down
14 changes: 13 additions & 1 deletion tools/loaders/esm.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import fs from 'fs-extra'
import path from 'path'
import { getFormat as getFormatTs, resolve as resolveTs } from 'ts-node/esm'
import {
install as tsPatch,
parseFiles as parse,
SRC_FILES as TSRC
} from 'ts-patch/lib/actions'
import { createMatchPath, loadConfig } from 'tsconfig-paths'
import useDualExports from '../helpers/use-dual-exports.mjs'

Expand All @@ -12,9 +17,16 @@ import useDualExports from '../helpers/use-dual-exports.mjs'

/** @typedef {'builtin'|'commonjs'|'dynamic'|'json'|'module'|'wasm'} Format */

const NODE_MODULES = process.env.NODE_MODULES
const { patchVersion } = parse(TSRC, `${NODE_MODULES}/typescript/lib`)[0]

// ! Add ESM-compatible export statement to `exports.default` statements
// ! Fixes: `TypeError: logger is not a function`
useDualExports([`${process.env.NODE_MODULES}/@flex-development/grease/cjs/**`])
useDualExports([`${NODE_MODULES}/@flex-development/grease/cjs/**`])

// Use TypeScript plugins
// See: https://github.com/nonara/ts-patch
if (!patchVersion) tsPatch()

/**
* ESM requires all imported files to have extensions. Unfortunately, most `bin`
Expand Down
57 changes: 36 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,8 @@ __metadata:
shelljs: 0.8.4
ts-jest: 27.0.5
ts-node: 10.2.1
ts-patch: 1.4.4
tsconfig-paths: 3.11.0
ttypescript: 1.5.12
typescript: 4.4.3
yargs: 17.2.1
peerDependencies:
Expand Down Expand Up @@ -4886,6 +4886,17 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"global-prefix@npm:^3.0.0":
version: 3.0.0
resolution: "global-prefix@npm:3.0.0"
dependencies:
ini: ^1.3.5
kind-of: ^6.0.2
which: ^1.3.1
checksum: 8a82fc1d6f22c45484a4e34656cc91bf021a03e03213b0035098d605bfc612d7141f1e14a21097e8a0413b4884afd5b260df0b6a25605ce9d722e11f1df2881d
languageName: node
linkType: hard

"globals@npm:^11.1.0":
version: 11.12.0
resolution: "globals@npm:11.12.0"
Expand Down Expand Up @@ -5240,7 +5251,7 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"ini@npm:^1.3.2, ini@npm:^1.3.4":
"ini@npm:^1.3.2, ini@npm:^1.3.4, ini@npm:^1.3.5":
version: 1.3.8
resolution: "ini@npm:1.3.8"
checksum: dfd98b0ca3a4fc1e323e38a6c8eb8936e31a97a918d3b377649ea15bdb15d481207a0dda1021efbd86b464cae29a0d33c1d7dcaf6c5672bee17fa849bc50a1b3
Expand Down Expand Up @@ -8409,7 +8420,7 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"resolve@>=1.9.0, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.12.0, resolve@^1.20.0":
"resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.12.0, resolve@^1.20.0":
version: 1.20.0
resolution: "resolve@npm:1.20.0"
dependencies:
Expand All @@ -8419,7 +8430,7 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"resolve@patch:resolve@>=1.9.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.1.6#~builtin<compat/resolve>, resolve@patch:resolve@^1.10.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.10.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.12.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.20.0#~builtin<compat/resolve>":
"resolve@patch:resolve@^1.1.6#~builtin<compat/resolve>, resolve@patch:resolve@^1.10.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.10.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.12.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.20.0#~builtin<compat/resolve>":
version: 1.20.0
resolution: "resolve@patch:resolve@npm%3A1.20.0#~builtin<compat/resolve>::version=1.20.0&hash=00b1ff"
dependencies:
Expand Down Expand Up @@ -8643,7 +8654,7 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"shelljs@npm:0.8.4":
"shelljs@npm:0.8.4, shelljs@npm:^0.8.4":
version: 0.8.4
resolution: "shelljs@npm:0.8.4"
dependencies:
Expand Down Expand Up @@ -9488,6 +9499,25 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"ts-patch@npm:1.4.4":
version: 1.4.4
resolution: "ts-patch@npm:1.4.4"
dependencies:
chalk: ^4.1.0
glob: ^7.1.7
global-prefix: ^3.0.0
minimist: ^1.2.5
resolve: ^1.20.0
shelljs: ^0.8.4
strip-ansi: ^6.0.0
peerDependencies:
typescript: ">2.7.0"
bin:
ts-patch: bin/cli.js
checksum: 527c30b891594c83466f7dc200912f816b4dc71a10dba2fbd964ce98287e52f580460d0962e4fa8751e0b8ec2b45b019eb52a4e4c31b05c988f2447d790eb07f
languageName: node
linkType: hard

"tsconfig-paths@npm:3.11.0, tsconfig-paths@npm:^3.11.0, tsconfig-paths@npm:^3.9.0":
version: 3.11.0
resolution: "tsconfig-paths@npm:3.11.0"
Expand Down Expand Up @@ -9525,21 +9555,6 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"ttypescript@npm:1.5.12":
version: 1.5.12
resolution: "ttypescript@npm:1.5.12"
dependencies:
resolve: ">=1.9.0"
peerDependencies:
ts-node: ">=8.0.2"
typescript: ">=3.2.2"
bin:
ttsc: bin/tsc
ttsserver: bin/tsserver
checksum: 91b6d113d2ce4c7f93392b97a6df38ad6ce6ad4c80227e3d2e1d6948c53f8664018060a02020d8f28a3e461876232b78b4c38352c546a02f3b543a062147fafa
languageName: node
linkType: hard

"type-check@npm:^0.4.0, type-check@npm:~0.4.0":
version: 0.4.0
resolution: "type-check@npm:0.4.0"
Expand Down Expand Up @@ -9920,7 +9935,7 @@ fsevents@^2.3.2:
languageName: node
linkType: hard

"which@npm:^1.2.9":
"which@npm:^1.2.9, which@npm:^1.3.1":
version: 1.3.1
resolution: "which@npm:1.3.1"
dependencies:
Expand Down

0 comments on commit 7c38efc

Please sign in to comment.