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

chore: use jiti for ts config loading #1474

Merged

Conversation

timofei-iatsenko
Copy link
Collaborator

@timofei-iatsenko timofei-iatsenko commented Mar 1, 2023

Description

As i mentioned:

i've found very promising https://github.com/unjs/jiti and https://github.com/unjs/c12 we should give them a try. These packages powering a Nuxt framework.

Unfortunately we can't use c12 because it load asynchonously but we can incorporate jiti instead of cosmiconfig-typescript-loader / ts-node.

Looks like jiti was created for such usecases, where ts-node is not. The benefit of using jiti over ts-node:

  1. Supports cache (v8, require and hard cache on the file system of transpiled files)
  2. Executes only this require in "context" of transpilation.

The problem with ts-node is that once it registered it starts processing all require calls in the current VM. That caused that not only config with it's dependecies get transpiled but also other code running in the same instance after register call.

Also all subsequent calls to TypeScriptLoader with ts-node would cause registering another instance of compiler for require module system and this is end up with out memory at certain point.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Fixes # (issue)

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@vercel
Copy link

vercel bot commented Mar 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 1, 2023 at 5:21PM (UTC)

@github-actions
Copy link

github-actions bot commented Mar 1, 2023

size-limit report 📦

Path Size
./packages/core/build/esm/index.js 1.72 KB (0%)
./packages/detect-locale/build/esm/index.js 812 B (0%)
./packages/react/build/esm/index.js 1.79 KB (0%)
./packages/remote-loader/build/esm/index.js 7.25 KB (0%)

@timofei-iatsenko timofei-iatsenko changed the title chore() use jiti for ts config loading chore: use jiti for ts config loading Mar 1, 2023
@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Patch coverage: 75.00% and project coverage change: -0.04 ⚠️

Comparison is base (094cb26) 74.02% compared to head (c7893b7) 73.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1474      +/-   ##
==========================================
- Coverage   74.02%   73.98%   -0.04%     
==========================================
  Files          68       68              
  Lines        1902     1903       +1     
  Branches      502      501       -1     
==========================================
  Hits         1408     1408              
- Misses        378      379       +1     
  Partials      116      116              
Impacted Files Coverage Δ
packages/cli/src/tests.ts 72.97% <60.00%> (-4.17%) ⬇️
packages/conf/src/getConfig.ts 86.66% <100.00%> (+5.41%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants