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

feat(message-utils): make generateMessageId to be working in browser #1776

Merged
merged 2 commits into from
Oct 4, 2023

Conversation

timofei-iatsenko
Copy link
Collaborator

Description

There is some demand to compile catalogs and messages on the fly. The generateMessageId function used nodejs api before, and it makes it not possible to use in the browser. There is a native WebCrypro api which supported in both browser and nodejs, but unfortunately it's async only and could not be used in babel macros transformation which is synchronous.

I've used a custom js sha256 implementation, which is according to theirs benchmark fast as a native implementation.

Also i did not like that tests for compileMessage Function is stored somewhere else, so i extracted them from api package.

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 Oct 3, 2023

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

Name Status Preview Comments Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2023 10:12am

@github-actions
Copy link

github-actions bot commented Oct 3, 2023

size-limit report 📦

Path Size
./packages/core/dist/index.mjs 2.83 KB (0%)
./packages/detect-locale/dist/index.mjs 721 B (0%)
./packages/react/dist/index.mjs 1.68 KB (0%)
./packages/remote-loader/dist/index.mjs 7.24 KB (0%)

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (efcd405) 76.24% compared to head (cd07ec2) 76.27%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1776      +/-   ##
==========================================
+ Coverage   76.24%   76.27%   +0.03%     
==========================================
  Files          81       81              
  Lines        2071     2074       +3     
  Branches      528      529       +1     
==========================================
+ Hits         1579     1582       +3     
  Misses        380      380              
  Partials      112      112              
Files Coverage Δ
packages/message-utils/src/generateMessageId.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@timofei-iatsenko timofei-iatsenko changed the title Make generateMessageId work in browser feat(message-utils): make generateMessageId to be working in browser Oct 3, 2023
@andrii-bodnar andrii-bodnar merged commit f879ddb into lingui:main Oct 4, 2023
14 of 15 checks passed
@timofei-iatsenko timofei-iatsenko deleted the refactor/compiler branch October 5, 2023 07:20
@JSteunou JSteunou mentioned this pull request Apr 30, 2024
44 tasks
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