question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing webpack context rules for requiring lazy messages file

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
rchlcommented, 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.

0reactions
rchlcommented, Feb 24, 2021

Sorry about that. Addressed with 01f92ae72ba2a37cda2be119f618751ab7dbf20b 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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing webpack context rules for requiring lazy messages file
Maybe it's because of require context who parse too much file extensions. A quick fix is to keep the langDir as light as...
Read more >
To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >
Module Federation - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
DevServer - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
MiniCssExtractPlugin - webpack
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); module.exports = { plugins: [new MiniCssExtractPlugin()], module: { rules: [ { test: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found