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(vite-plugin): change default export to named export #1465

Merged
merged 2 commits into from
Feb 24, 2023

Conversation

thekip
Copy link
Collaborator

@thekip thekip commented Feb 24, 2023

Description

I don't see a way to fix that other than change default export to named.

if i make vite-plugin package true ESM, it requires other packages also being ESM (lingui/conf + lingue/cli/api)
and that's not possible for many different reasons
Usually, when you use transpires, they insert an "interop" for all default imports. That interop actually checking if there a "default" property.
Native nodejs ESM loader obviously doesn't have it. So commonjs modules transpiled from ESM source is not supported by node in aspects of default exports.

it's a common issue in other packages as well. So to normally work with native ESM you either should be fully ESM itself, or not use default export as a workaround.

Now package exports both, default and named exports. I also updated documentation to use named export.

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 #1449

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 Feb 24, 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 Feb 24, 2023 at 9:49AM (UTC)

@thekip thekip changed the title Fix/vite plugin export fix(vite-plugin): change default export to named export Feb 24, 2023
@github-actions
Copy link

size-limit report 📦

Path Size
./packages/core/build/esm/index.js 1.76 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.29 KB (0%)

@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Base: 73.63% // Head: 69.52% // Decreases project coverage by -4.11% ⚠️

Coverage data is based on head (b8c6ec9) compared to base (1288228).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1465      +/-   ##
==========================================
- Coverage   73.63%   69.52%   -4.11%     
==========================================
  Files          79       72       -7     
  Lines        2905     2146     -759     
  Branches      861      581     -280     
==========================================
- Hits         2139     1492     -647     
+ Misses        606      519      -87     
+ Partials      160      135      -25     
Impacted Files Coverage Δ
packages/vite-plugin/src/index.ts 85.71% <0.00%> (-2.53%) ⬇️
packages/cli/src/api/extractors/babel.ts 54.54% <0.00%> (-28.79%) ⬇️
packages/cli/src/api/stats.ts 70.00% <0.00%> (-10.00%) ⬇️
packages/macro/src/index.ts 83.87% <0.00%> (-6.94%) ⬇️
packages/cli/src/lingui-compile.ts 30.58% <0.00%> (-6.26%) ⬇️
packages/cli/src/api/catalog.ts 85.77% <0.00%> (-4.40%) ⬇️
...ackages/babel-plugin-extract-messages/src/index.ts 80.95% <0.00%> (-4.14%) ⬇️
packages/cli/src/api/formats/po-gettext.ts 82.53% <0.00%> (-3.50%) ⬇️
packages/jest-mocks/index.ts 95.83% <0.00%> (-1.47%) ⬇️
... and 18 more

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.

@andrii-bodnar andrii-bodnar merged commit 15510c1 into lingui:main Feb 24, 2023
@thekip thekip deleted the fix/vite-plugin-export branch February 24, 2023 10:40
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.

Vite plugin -> lingui is not a function in new Vite + React + TS project
3 participants