-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
chore: update jiti to v2 #10716
base: main
Are you sure you want to change the base?
chore: update jiti to v2 #10716
Conversation
⚡️ Lighthouse report for the deploy preview of this PR
|
No dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No dependency changes detected in pull request |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
I already tried to upgrade and couldn't make it work 😅 It looks problematic if only one of those exports works while previously both worked: export const dep1Export = "dep1 val1";
export default {dep1Val: "dep1 val2"} Maybe the current version is not correct, but users rely on it and I'm afraid if we change that behavior we'll have to wait v4 |
Yeah, agreed. There were about ~15 tests broken with a straight upgrade but I managed to get it down to 2. It seems like the If I use The real issue is that if I upgrade to I'm going to get a reduced test case to cover these issues in the jiti repo, but if you've got any thoughts, I'd be happy to run them down a little further.
|
@slorber I've been thinking about the current behavior a little more and there is potential to overwrite a property on the default export with a named export: // file1.ts
export const named = 42;
export default {
named: 43
} // file2.ts
const mod = require('./file1.ts');
console.log(mod.named) // 42 It's expected behavior now since it's how jiti@1 works but it feels like something that probably should change in v4. Maybe a full changeover to ESM? |
Honestly, all this feels hard to reason about 🤯 I'm not sure how this interop mode works for the entrypoint, the transitive modules and if this behaves differently for cjs/esm in both case. I think we should ditch the existing test assertions and just rewrite them all with new settings. Like if we implemented this from scratch again. I don't think there's an "ideal interop setup", the tests are mostly here to "freeze" the behavior we have for a given major version, ensuring we keep this behavior. But as far as I understand, users can already alter this behavior with env variables. And it should be fine to change that behavior in major versions. But it will probably require to document the breaking change so we should at least understand a bit how the behavior changed between 2 major versions 😅 |
I've been talking with jiti maintainer over in unjs/jiti#341 about it and it's agreed there is a difference between 2.1 and 2.2 as well as a proposed fix. Are you saying you want to upgrade to jiti@latest and replace the test cases with how the new version behaves for release with docusaurus@4? |
Yes, I guess we move the tests to use snapshots instead of assertions. And when upgrading Jiti, we can just update the snapshots to freeze the behavior expectation. If the behavior changes, but overall the system still seems legit and we can document a bit how users should update their config/sidebar/plugin code, I think it's fine. If we target v4 we can do whatever breaking change we want, including removing the interop or even dropping CJS support. It's preferable to not annoy the users for no good reason though but the behavior can definitively change and we can consider the current tests do not exist. |
Ok, I'll take a look at doing a separate PR that updates the tests to snapshots and then revisit this one after that is merged. Thanks! |
* Testing a new way to interact with park * Squashed 'api/' content from commit 06e27942d git-subtree-dir: api git-subtree-split: 06e27942d1def5348e4c82cd6b5afd8b4e79422d * Migrating to docusaurus-plugin-typedoc-api * Added libraries, experimental - TODO: Check library entry points. * Squashed 'api/typedoc-plugin/' content from commit b069bc730 git-subtree-dir: api/typedoc-plugin git-subtree-split: b069bc730f29af206c42684c09cdeb6b39d50f00 * Moved packages/plugin/docusaurus-plugin-typedoc-api to docusaurus-typedoc-plugin * Bump @Docusaurus dependencies (3.6.1 -> 3.6.3) * Removed typedoc-codicon-theme, since it cannot be used anymore * Properly linting markdown, ignoring images links * Added plugin building to package * Compiling plugin with typescript, copying assets * Removed plugin footer, useless one * Typedoc 0.26+ uses ReflectionId as identifier (still number, but with exceptions) * Plugins should use @theme-init instead of @theme * Added typedoc 0.26+ document icon * Added Options type export to entry point, using it in docusaurus.config.ts * Downgrading to Typedoc 0.25.13 until jiti-v2 is coming out to Docusaurus - See facebook/docusaurus#10716 for details. * Migrating plugin back too for now * Moving plugin to @nernar/docusaurus-plugin-typedoc, migrating to Docusaurus 3.5.2 * Added libraries tsconfig stuff * Moved declarations to new location * Added libraries packages to API * Some dirty stuff to make it work
* Testing a new way to interact with park * Squashed 'api/' content from commit 06e27942d git-subtree-dir: api git-subtree-split: 06e27942d1def5348e4c82cd6b5afd8b4e79422d * Migrating to docusaurus-plugin-typedoc-api * Added libraries, experimental - TODO: Check library entry points. * Squashed 'api/typedoc-plugin/' content from commit b069bc730 git-subtree-dir: api/typedoc-plugin git-subtree-split: b069bc730f29af206c42684c09cdeb6b39d50f00 * Moved packages/plugin/docusaurus-plugin-typedoc-api to docusaurus-typedoc-plugin * Bump @Docusaurus dependencies (3.6.1 -> 3.6.3) * Removed typedoc-codicon-theme, since it cannot be used anymore * Properly linting markdown, ignoring images links * Added plugin building to package * Compiling plugin with typescript, copying assets * Removed plugin footer, useless one * Typedoc 0.26+ uses ReflectionId as identifier (still number, but with exceptions) * Plugins should use @theme-init instead of @theme * Added typedoc 0.26+ document icon * Added Options type export to entry point, using it in docusaurus.config.ts * Downgrading to Typedoc 0.25.13 until jiti-v2 is coming out to Docusaurus - See facebook/docusaurus#10716 for details. * Migrating plugin back too for now * Moving plugin to @nernar/docusaurus-plugin-typedoc, migrating to Docusaurus 3.5.2 * Added libraries tsconfig stuff * Moved declarations to new location * Added libraries packages to API * Some dirty stuff to make it work
By the way, Node is looking to unflag TS type stripping support Looks like we may even be able to remove Jiti in the future. Maybe we should postpone this update and directly aim for native TS support instead? See also nodejs/typescript#17 (comment) |
I should have time to work on the testing PR and the jiti issue upstream before the end of the month. Are you looking at 4.0 release soon? |
Not that soon, probably early 2025 I'd like to upgrade to React 19 and React Router 7, among other things. Not sure all our peer dependencies are ready for that yet, we'll see soon. |
Pre-flight checklist
Motivation
In adding an example for
@shikijs/rehype
, a few community members noticed that it doesn't work with the installed version ofjiti
Test Plan
Almost all of the tests pass with the changes to
moduleUtils
. The only test that does not pass is the one below.Test links
Deploy preview: https://deploy-preview-10716--docusaurus-2.netlify.app/
Related issues/PRs
comment in #9122