Skip to content

feat: convert to typescript and esm#77

Merged
lukekarrys merged 3 commits intomainfrom
lk/isaacs/main-ts
Nov 16, 2023
Merged

feat: convert to typescript and esm#77
lukekarrys merged 3 commits intomainfrom
lk/isaacs/main-ts

Conversation

@lukekarrys
Copy link
Copy Markdown
Contributor

@lukekarrys lukekarrys commented Oct 31, 2023

BREAKING CHANGE: read is now written in TypeScript and types are now
shipped as part of this package.

BREAKING CHANGE: read now only exports a named export { read }
and does not have a default export.


TODO:

  • Set required template-oss configs so it template-oss-check passes
  • Get eslint import config working with typescript + .js files (or use allowImportingTsExtensions)
  • Add typescript eslint plugin
  • Update engines
  • Use TypeScript, ESM, tap18 support template-oss#371 instead of local tarball

@lukekarrys lukekarrys changed the title lk/isaacs/main ts Convert to TypeScript Hybrid CJS + ESM Oct 31, 2023
@lukekarrys
Copy link
Copy Markdown
Contributor Author

lukekarrys commented Oct 31, 2023

@isaacs any thoughts on the tsconfig.json or tshy+tap setup would be greatly appreciated. this is based on #44 and updated to replace the previous ts+esm/cjs config with tshy and tap@18.

also does it need a separate read.d.ts file if the types are exported from read.ts?

Copy link
Copy Markdown
Contributor

@isaacs isaacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes suggested.

And yes, definitely remove the read.d.ts if this is being written in TS, it will be extraneous and just serve to confuse things. Better to let TS find the appropriate dialect-specific types in dist.

@lukekarrys
Copy link
Copy Markdown
Contributor Author

Made all the changes suggested. I was not set on a default export, and I think TypeScript+ESM is a good push for us to end the pattern module.exports = () => {}; module.exports.x = 1;

@isaacs
Copy link
Copy Markdown
Contributor

isaacs commented Nov 1, 2023

Those node 14 tests are never going to pass with tap 18, probably best to remove from the matrix.

@lukekarrys
Copy link
Copy Markdown
Contributor Author

yes node 14 is definitely getting dropped as part of this PR

import { spawn } from 'child_process'
import { fileURLToPath } from 'url'

const esc = (str: string) => str.replace(/([()])/g, '\\$1')

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.
@lukekarrys lukekarrys marked this pull request as ready for review November 3, 2023 17:05
@lukekarrys lukekarrys requested a review from a team as a code owner November 3, 2023 17:05
@wraithgar
Copy link
Copy Markdown
Member

wraithgar commented Nov 3, 2023

If we're bumping engines let's bump engines

npm view npm engines
{ node: '^18.17.0 || >=20.5.0' }
$ npm query '#read' |json -a _id from
read@2.1.0 [
  "node_modules/init-package-json",
  "node_modules/promzard",
  "workspaces/libnpmexec",
  ""
]

@lukekarrys lukekarrys force-pushed the lk/isaacs/main-ts branch 6 times, most recently from 2702dc8 to d604cc1 Compare November 6, 2023 17:29
@lukekarrys lukekarrys force-pushed the lk/isaacs/main-ts branch 4 times, most recently from d3d2501 to 1e61bc0 Compare November 6, 2023 18:35
@lukekarrys lukekarrys marked this pull request as draft November 6, 2023 18:36
@lukekarrys lukekarrys marked this pull request as ready for review November 16, 2023 03:01
@lukekarrys lukekarrys force-pushed the lk/isaacs/main-ts branch 2 times, most recently from 4ba826a to 51e6b4d Compare November 16, 2023 03:19
@lukekarrys lukekarrys marked this pull request as draft November 16, 2023 03:19
@lukekarrys lukekarrys changed the title Convert to TypeScript Hybrid CJS + ESM feat: convert to typescript and esm Nov 16, 2023
@lukekarrys lukekarrys marked this pull request as ready for review November 16, 2023 14:49
@lukekarrys
Copy link
Copy Markdown
Contributor Author

This is now using @npmcli/template-oss@4.20.0 and has been squashed down to single commit.

@wraithgar It also removes the engines update entirely as I dropped it back to tap@16 + c8 and ts-node to avoid that issue for now.

BREAKING CHANGE: `read` is now written in TypeScript and types are now
shipped as part of this package.

BREAKING CHANGE: `read` now only exports a named export `{ read }`
and does not have a default export.
@lukekarrys
Copy link
Copy Markdown
Contributor Author

Bumped out of date devDeps and adding TODO comments for all ignored coverage.

@lukekarrys lukekarrys merged commit 18cb7bd into main Nov 16, 2023
@lukekarrys lukekarrys deleted the lk/isaacs/main-ts branch November 16, 2023 15:52
@github-actions github-actions bot mentioned this pull request Nov 16, 2023
marmitar added a commit to marmitar/thelounge that referenced this pull request Nov 4, 2025
Important changes (npm/read#77):
- exported as ESM
- includes type definitions
- no callback API (npm/read#40)

It was possible to recreate the callback API using `Promise.then`,
but it's not really worth it in this case.
marmitar added a commit to marmitar/thelounge that referenced this pull request Nov 17, 2025
Important changes (npm/read#77):
- exported as ESM
- includes type definitions
- no callback API (npm/read#40)

It was possible to recreate the callback API using `Promise.then`,
but it's not really worth it in this case.
marmitar added a commit to marmitar/thelounge that referenced this pull request Jan 31, 2026
Important changes (npm/read#77):
- exported as ESM
- includes type definitions
- no callback API (npm/read#40)

It was possible to recreate the callback API using `Promise.then`,
but it's not really worth it in this case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants