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

refactor: move getUserConfig to cli utils #59

Closed

Conversation

jkjustjoshing
Copy link
Contributor

@jkjustjoshing jkjustjoshing commented Oct 25, 2022

Issue

When importing localizeUrl() into Astro components, the build failed because @proload packages were being imported in the same file, and Vite doesn't know how to transpile @proload.

import { localizeUrl } from 'astro-i18next';

image

Proposal

I'm proposing the following change:

  •  import { localizeUrl } from 'astro-i18next/utils';
    
  • Updating the build script to output a utils.js from src/utils.ts
  • Expose utils.js as astro-i18next/utils from package.json

Discussion

I realize I submitted this PR without a corresponding Issue. I'm happy to make that issue, close this PR, and discuss the best solution there before moving forward with a code implementation.
For my project, I needed this change made today, so I figured I'd also submit it back to the project as a proposal.

@codecov-commenter
Copy link

Codecov Report

Base: 98.93% // Head: 99.02% // Increases project coverage by +0.08% 🎉

Coverage data is based on head (ff05865) compared to base (9281d7e).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #59      +/-   ##
===========================================
+ Coverage    98.93%   99.02%   +0.08%     
===========================================
  Files            4        4              
  Lines          377      409      +32     
  Branches        47       47              
===========================================
+ Hits           373      405      +32     
  Misses           4        4              
Impacted Files Coverage Δ
src/utils.ts 100.00% <ø> (ø)
src/cli/utils.ts 100.00% <100.00%> (ø)

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.

@jkjustjoshing jkjustjoshing marked this pull request as draft October 25, 2022 20:52
When importing localizeUrl() into Astro components, the build failed
because @ProLoad packages were being imported in the same file, and Vite
doesn't know how to transpile @ProLoad.
This moves @proload-dependent code into a separate file, so other ./utils
methods can be imported in Astro code
@jkjustjoshing
Copy link
Contributor Author

I've realized my issue is that I'm not actually importing this file into an Astro component, I'm importing this file into a React component that is being pulled in with client:load. So the solution to this will be the same as #46 - the client needs access to the i18next instance

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