Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): switch to esbuild and tsc #279

Merged
merged 7 commits into from
Jun 1, 2023
Merged

fix(build): switch to esbuild and tsc #279

merged 7 commits into from
Jun 1, 2023

Conversation

kfcampbell
Copy link
Member

@kfcampbell kfcampbell commented Jun 1, 2023

Replicating octokit/request.js#584 to another repo.

Consumers of this module such as oauth-methods.js#152 are seeing missing types. This PR attempts to fix that issue by getting us off of pika before additional Node deprecations can be made.

Note that when running npm run build locally, I see the following errors:

 sh$ npm run build

> @octokit/oauth-authorization-url@0.0.0-development build
> node scripts/build.mjs && tsc -p tsconfig.json

✘ [ERROR] Could not resolve "./types"

    pkg/dist-src/index.js:7:7:
      7 │ } from "./types";
        ╵        ~~~~~~~~~

✘ [ERROR] Could not resolve "./types"

    pkg/dist-src/index.js:7:7:
      7 │ } from "./types";
        ╵        ~~~~~~~~~

These errors are not present in the CI build because npm run build does not appear to be run then. I believe this to be a configuration issue and I think I missed something in this repo to get this to function correctly. Tips are appreciated!


Pika has been deprecated for a while now, and the project has now been archived, and because of that the released npm package is missing most of the files generated by the build step.

Uses esbuild to transpile the TS source code into an ESM source, NodeJs bundle, and a browser bundle

Uses the TypeScript compiler to generate the types.

Behavior

Before the change?

  • Uses pika for the build system
  • The released npm package is missing most of the files generated by the build step. dist-node, dist-types, dist-web... even though they are generated correctly.

After the change?

  • Uses esbuild to generate the JS bundles
  • Uses the TypeScript compiler to generate the type definitions
  • The correct file matching patterns are used so we publish all the necessary files again.

Additional info

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Added the appropriate label for the given change

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes (Please add the Type: Breaking change label)
  • No

If Yes, what's the impact:

  • N/A

Pull request type

Please add the corresponding label for change this PR introduces:

  • Bugfix: Type: Bug
  • Dependencies/code cleanup: Type: Maintenance

@kfcampbell kfcampbell added Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR and removed maintenance labels Jun 1, 2023
@kfcampbell kfcampbell marked this pull request as ready for review June 1, 2023 18:39
Copy link
Member

@wolfy1339 wolfy1339 left a comment

Choose a reason for hiding this comment

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

Some quick things I noticed

scripts/build.mjs Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@wolfy1339
Copy link
Member

The errors are because you need to explicitly mark type imports/exports

kfcampbell and others added 2 commits June 1, 2023 12:05
Co-authored-by: wolfy1339 <4595477+wolfy1339@users.noreply.github.com>
Co-authored-by: wolfy1339 <4595477+wolfy1339@users.noreply.github.com>
@kfcampbell kfcampbell requested a review from wolfy1339 June 1, 2023 19:07
@kfcampbell
Copy link
Member Author

@wolfy1339 thanks for the tip! After applying your changes I'm still seeing the same errors...is there another spot where an import/export is missed?

@wolfy1339
Copy link
Member

There probably are more places in the code that need updating

@kfcampbell kfcampbell changed the title Initial attempt at switching to esbuild and tsc Switch to esbuild and tsc Jun 1, 2023
@kfcampbell
Copy link
Member Author

Aha! Here is what was missing. npm run build succeeds for me locally and I think this is ready to go.

Copy link
Member

@wolfy1339 wolfy1339 left a comment

Choose a reason for hiding this comment

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

LGTM, some small style issues.

scripts/build.mjs Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
@kfcampbell kfcampbell changed the title Switch to esbuild and tsc fix(build): switch to esbuild and tsc Jun 1, 2023
@kfcampbell kfcampbell merged commit 2837e82 into main Jun 1, 2023
@kfcampbell kfcampbell deleted the switch-to-esbuild branch June 1, 2023 21:28
@github-actions
Copy link

github-actions bot commented Jun 1, 2023

🎉 This PR is included in version 6.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants