-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Migrate Ink to ESM and update React #546
Conversation
], | ||
"require": [ | ||
"ts-node/register/transpile-only" | ||
"extensions": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on updating the tests to ESM and fixing them.
@sindresorhus I might need your help to get the tests passing. For some reason when I run the tests they time out without any useful output. My guess is that the |
That tricked worked 🚀. Thanks a lot @sindresorhus. I'll work on fixing the tests and I'll let you know when the PR is ready for a review. |
Thanks for this massive contribution, @pepicrft! Let me know when it's ready to review 👍 |
You can change CI to only test Node.js 14, 16 and 18, since 10 and 12 aren't maintained anymore. This will allow tests to run in this PR. |
benchmark/static/static.tsx
Outdated
@@ -1,7 +1,9 @@ | |||
#!/usr/bin/env npx ts-node-esm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the approach here. Instead of using import-jsx
in an index.js
file I added a shebang at the top to run the script through ts-node-esm
, which will use Node loaders to transform the module into standard JS.
test/errors.tsx
Outdated
}); | ||
|
||
test.after(() => { | ||
restore(); | ||
}); | ||
|
||
test('catch and display error', t => { | ||
test.skip('catch and display error', t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vadimdemedes the output changed and it's causing the test to fail. Where is the formatting of the error happening?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors are caught in App
component (src/components/App.tsx) and formatted inside ErrorOverview
component (src/components/ErrorOverview.tsx).
Quick update here @vadimdemedes & @sindresorhus:
There are some remaining bits but I'm a bit blocked with them:
I'd appreciate your help to get this one to the finish line 🙏🏼 |
Not sure what's happening yet, but running
Have you encountered this before? I deleted |
Same error is actually happening on CI. Interestingly, XO fails differently on Node.js 14 and 18 on CI. |
Ouch :/. It is possible then that the test's implementation depends on the environment in which it runs. |
Oh my, after several days of debugging, I finally fixed the For context, Ink has 3 rendering modes:
When I ran this PR's tests locally,
But the first "Hello world" was never displayed on CI. I started adding a bunch of Since it worked before this PR, there must've been some change in how CI enivronment is detected. I traced it down to this commit in Looks like deleting So here's the fix → pepicrft@67d7a8a. |
The last thing to figure out before shipping this PR is a replacement of import-jsx, since it's not supported in ESM anymore. It seems to be quite popular, so we need to have either a replacement or some recommendations in the migration guide. |
Submitted vadimdemedes/import-jsx#18 to support ESM in |
Just WOW on that thorough debugging. I wouldn't have been able to figure that out myself. |
Replied in vadimdemedes/import-jsx#18 (comment).
Yep, here are the packages I wanted to update too:
Going to start working on these too and report back. |
Thanks for an amazing contribution, @pepicrft 🚢 |
Thanks a lot @vadimdemedes and @sindresorhus for supporting through this effort. It's a pleasure contributing to open source projects like Ink. |
@vadimdemedes when is the next release going out? |
Ideally I want to have the other projects I linked to above converted to ESM too, so that all of them are released roughly at the same time. |
Resolves #543
I'm migrating this package to ESM to nudge the ecosystem towards embracing the standards.
@sindresorhus/tsconfig
exports
attribute in thepackage.json
.moduleResolution
andmodule
attributes in thetsconfig.json
tonode16