Skip to content

chore: migrate to esm#465

Draft
Miablo wants to merge 5 commits intogithub-community-projects:mainfrom
Miablo:esm-migration
Draft

chore: migrate to esm#465
Miablo wants to merge 5 commits intogithub-community-projects:mainfrom
Miablo:esm-migration

Conversation

@Miablo
Copy link
Copy Markdown
Contributor

@Miablo Miablo commented May 4, 2026

Pull Request

Proposed Changes

Closes #331

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run npm run format and fix any formatting issues that have been introduced
  • run npm run lint and fix any linting issues that have been introduced
  • run npm run test and run tests

@Miablo Miablo self-assigned this May 4, 2026
@Miablo
Copy link
Copy Markdown
Contributor Author

Miablo commented May 4, 2026

Note: still need to test end to end to make sure everything is running correctly especially the web hooks

Copy link
Copy Markdown
Contributor

@wrslatz wrslatz left a comment

Choose a reason for hiding this comment

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

I know it's still in draft, but I left a few suggestions based on my understanding of migrating to ESM and some quick spot checking against resources and searching.

Since Private Mirrors only supports Node.js 22 and above, I believe the project could interop with ESM and CJS dependencies where it could not before, so the same ESM errors may not be present as before. Also, since the project is not published as a JS package, pure ESM has less impact to downstream consumers. I still think it's worth while to adopt.

Comment thread package.json
"type-check": "tsc --noEmit",
"bot:build": "tsc ./src/bot/index.ts --noEmit false --esModuleInterop --outDir ./build",
"bot:start": "probot run ./build/index.js",
"bot:start": "tsx ./src/bot/main.ts",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we are using a new enough Node.js, we may be able to run directly using node since type stripping for TypeScript is now supported.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed on type stripping but I'm not sure that we need these scripts at all. I suppose you could use this to run the webhook handling logic in conjunction with the webhook relay but the dev script already includes this alongside the rest of the app and is set up to run the relay with concurrently.

Comment thread package.json
"format": "prettier --check .",
"format:fix": "prettier --write .",
"type-check": "tsc --noEmit",
"bot:build": "tsc ./src/bot/index.ts --noEmit false --esModuleInterop --outDir ./build",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For building, we could likely continue to use tsc or potentially use something like esbuild

Comment thread tsconfig.json
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "preserve" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be ESNext or NodeNext, I believe

Comment thread tsconfig.json
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"moduleResolution": "bundler" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be NodeNext I believe

Comment thread .prettierrc.cjs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should should be .mjs suffixed, I believe

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ideally I preferprettier.config.mjs. This page has the different options in the order they are referenced but I like that format since it matches eslint's config file. You can also add // @ts-check to the top of the file so it's treated the same as the rest of our typescript code. While you can use the .ts extension there is some trickiness there mentioned in the eslint docs.

@wrslatz
Copy link
Copy Markdown
Contributor

wrslatz commented May 4, 2026

Renovate's tsconfig may be a good one to compare against, for this change and for other settings: https://github.com/renovatebot/renovate/blob/main/tsconfig.json

@riley-kohler
Copy link
Copy Markdown
Contributor

Renovate's tsconfig may be a good one to compare against, for this change and for other settings: https://github.com/renovatebot/renovate/blob/main/tsconfig.json

I'm partial to the tsconfig bases that you pointed me at at one point. They have one for Next.js which should hopefully simplify the tsconfig a lot. On a typical project we would want to extend node24 and node-ts configs but I'm not sure how they might cross over with the Next one. I think node-ts should probably still be used (or referenced for additions) to ensure that we can use --experimental-strip-types instead of needing to use tsx.

@wrslatz
Copy link
Copy Markdown
Contributor

wrslatz commented May 4, 2026

I'm partial to the tsconfig bases that you pointed me at at one point. They have one for Next.js which should hopefully simplify the tsconfig a lot. On a typical project we would want to extend node24 and node-ts configs but I'm not sure how they might cross over with the Next one. I think node-ts should probably still be used (or referenced for additions) to ensure that we can use --experimental-strip-types instead of needing to use tsx.

Good call. We should be able to merge together a couple of these at least and get the recommended settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to ESM

3 participants