-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
feat(core): support TypeScript + ESM configuration #9317
Merged
+2,051
−911
Merged
Changes from 11 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
3f54f4f
feat: support typescript configuration
harryzcy b9db574
Apply suggestions from code review
harryzcy b88e1c8
fix: handle function typed config
harryzcy bb5b90a
Merge branch 'main' into config-in-ts
harryzcy 0f66191
chore: remove other usage of `import-fresh`
harryzcy 8f48f9d
chore: remove `import-fresh` in package.json
harryzcy 138e25e
fix: fix tests related to config loading
harryzcy 901c95e
fix: test case when config is promise
harryzcy 3913aa8
chore: add testcase for typescript
harryzcy b9a12d3
Merge branch 'main' into config-in-ts
slorber 6932057
Attempt to use TS sidebar
slorber 201c874
Hide jiti behind Docusaurus utils loadFreshModule abstraction
slorber a7752ab
Merge branch 'main' into config-in-ts
slorber 7af9f72
Add more loadSiteConfig test fixtures
slorber 1e4d95e
scaffold loadFreshModule tests
slorber 2c4a2e7
loadFreshModule tests for CJS / ESM
slorber 2f522b2
add loadFreshModule tests
slorber 5468bf9
Migrate templates to ESM
slorber d187645
Refactor init templates to ESM + TS
slorber 5b120e6
add @docusaurus/types to templates by default
slorber 80fb76d
refactor TS docs
slorber bad83af
update docs to ESM
slorber 4a36942
remove useless require.resolve from docs
slorber 81e2ec6
do not show CJS usage of remark-math plugin because it doesn't work a…
slorber 5c764a3
docs cleanups + use consistant module quotes in docs
slorber 4f9047c
docs cleanups
slorber a646e41
refactor docs pages for ESM/TS support
slorber 9ac8565
add ts config loading test
slorber c94aee2
Test support for ESM / TS presets
slorber 2b72d98
Add plugins loading ESM + TS tests
slorber d6ea99a
esm config
slorber 6105396
remove useless require.resolve
slorber 0a20fbd
migrate website config to TS
slorber 0fe678b
migrate website config to TS
slorber 2355ade
fix docs Joi import
slorber 88e7d63
fix getSwizzleComponentList docs
slorber 2cf10ee
fix ideal image type consistency
slorber b165e1d
migrate more website config to TS
slorber b9248dd
migrate more website config to TS
slorber 71666f2
migrate more website config to TS
slorber 047e394
migrate more website config to TS
slorber 7c1cc5e
fix pwa error
slorber 708c32f
fix weird changelog plugin bug due to using CJS?
slorber 3e53198
more website config refactors
slorber dd40aea
lint
slorber 729b6f8
refactor mdx plugin docs
slorber 22b7c8c
refactor mdx plugin docs
slorber 4f3e37b
lint
slorber 67c333e
templates should use ESM
slorber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/docusaurus/src/server/__tests__/__fixtures__/config/configTypescript.config.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This does not look like a drop-in replacement for
importFresh
unfortunately.Calling it multiple times will return the same result despite changing the underlying file.
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.
Hi. You can set
requireCache: false
in order to disable (runtime) cache.cache
option is for filesystem transform cache (and can be even kept enabled for better performance. you still will get a fresh value each time).Please let me know if could help further on this :)
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.
Also, we are working on new API
jiti.import()
(releasing by next week) if PR was delayed until then would be nice that you consider the migration for better future compatibility. It can bring support more native ESM compatibilities.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.
Thanks a lot @pi0 that's working. I saw
requireCache
in an older issue but thought it was an older removed option because it's not in v1 or v2 docs. But it's in the type and seems to work as I expect 👍Regarding
jiti.import()
(unjs/jiti#174?) I assume you want to say v2.0 is being released soon?On my side I didn't expect to migrate away from
importFresh
in Docusaurus v3 but as jiti seems to work that would be a awesome improvement for our users so I'm already delaying a bit our official release to incorporate this PR 😄 I'd prefer to not be an early adopter of jiti v2 this time, for timing reasons it's preferable if we upgrade for Docusaurus v4 (or in a minor version later, if not considered as a breaking change)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.
Ah awesome!
jiti.import()
API will be also released as a backward compatible stub for v1 for future compatibility so you can migrate earlier and only bump the major version of jiti later -- which i expect no major breaking changes. bumping to v2 is to make sure ecosystem migration is not risky. (i am on holidays with family RN but might find some time to do it earlier). v2 is not expected that soon.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.
Great, thanks :)
From what I understand currently Jiti is able to load modules synchronously but import will be async so it's probably better to assume async usage in the future?