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

Missing webpack context rules for requiring lazy messages file #1068

Closed
1 of 2 tasks
existe-deja opened this issue Feb 18, 2021 · 6 comments · Fixed by #1070 or hisan92/hisan.me#119
Closed
1 of 2 tasks

Missing webpack context rules for requiring lazy messages file #1068

existe-deja opened this issue Feb 18, 2021 · 6 comments · Fixed by #1070 or hisan92/hisan.me#119
Labels

Comments

@existe-deja
Copy link

Version

nuxt-i18n: 6.20.1
nuxt: 2.15.0

Nuxt configuration

mode:

  • universal
  • spa

Nuxt-i18n configuration

i18n: {
locales: [{ code: "fr", file: "fr.js" }],
langDir: "lang/lazyDir",
defaultLocale: "fr",
lazy: true
}

Reproduction Link

https://codesandbox.io/s/romantic-hamilton-o1ijf?file=/lang/README.md

Steps to reproduce

Insert a .md file inside the folder where lazy files are loaded (aka langDir property)

What is Expected?

No webpack warnings for unhandled files.

What is actually happening?

Webpack wants me to handle the md files. It throws this warning

./lang/lazyDir/README.md 1:5
Module parse failed: Unexpected token (1:5)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

Thoughts

Maybe it's because of require context who parse too much file extensions.
A quick fix is to keep the langDir as light as possible without md files, and require messages from another folder.

@rchl
Copy link
Collaborator

rchl commented Feb 18, 2021

I'll only try to load files with js, ts, and json extensions. Let me know if you can think of any other that should be included.

@existe-deja
Copy link
Author

I think this is fine. Well done for reactivity 👏

@rchl
Copy link
Collaborator

rchl commented Feb 19, 2021

@kedrzu
Copy link

kedrzu commented Feb 24, 2021

Would appreciate adding YAML files to the list (yml, yaml).

@kedrzu
Copy link

kedrzu commented Feb 24, 2021

Up until now, the module was able to handle any file, that webpack would recognize. So changing this behavior is really a breaking change, not just a fix - for example breaking my application as soon as I bumped the library.

Also, it maybe would be nice to add the possibility to define custom file types in the config.

@rchl
Copy link
Collaborator

rchl commented Feb 24, 2021

Sorry about that. Addressed with 01f92ae and released in https://github.com/nuxt-community/i18n-module/releases/tag/v6.20.3

Also, it maybe would be nice to add the possibility to define custom file types in the config.

I will consider that if there is really a need for it (that is if someone complains again).

This was referenced Mar 9, 2021
This was referenced Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment