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: improvements #8

Merged
merged 7 commits into from Dec 10, 2018
Merged

feat: improvements #8

merged 7 commits into from Dec 10, 2018

Conversation

manniL
Copy link
Member

@manniL manniL commented Dec 5, 2018

Key features:

  • Use inject
  • Update deps
  • Add defaultLocale option

Resolves #6
Resolves #5
Resolves #4
Resolves #3

@manniL manniL requested a review from pi0 December 5, 2018 18:12

export default (ctx, inject) => {
inject('moment', moment)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will introduce unnecessary extra load to each SSR request.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you'd vote to not inject moment (but using Vue.prototype instead)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'm aware of the nuxt reload problem. Because of shared Vue instance, any config change for moment module is not being applied unless stop/start nuxt again. Anyway, I think it worth to fix the root problem instead of making production builds slower. We have 3 options:

  • For now, use inject to prevent that problem and accept extra load until Nuxt.js fix
  • Use a conditional if for the template to use non-inject method for production only
  • Just making users aware of such development inconsistency and keep it as is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because several issues stated that ppl want to use it with ctx, so also on server side.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manniL Honestly this was not the purpose of this module and moment can be easily imported whenever needed which is fully SSR safe too. BTW I agree with that. Let's keep using inject :)

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other changes LGTM

@manniL
Copy link
Member Author

manniL commented Dec 5, 2018

I don't get why the test are failing...
image

@pi0 pi0 changed the title Improve module feat: improvements Dec 10, 2018
@pi0 pi0 merged commit 98c790d into master Dec 10, 2018
@pi0 pi0 deleted the improve branch December 10, 2018 08:18
@pi0
Copy link
Member

pi0 commented Dec 10, 2018

@manniL I'll fix tests on master as they are failing there too

@titogarrido
Copy link

How to use this module inside a store?

@arishojaei arishojaei mentioned this pull request Jul 1, 2021
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.

Set default locale undefined in middleware context Can't use in plugin can't use in store.
3 participants