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

Webpack 5 support #879

Closed
gurkerl83 opened this issue Nov 9, 2020 · 4 comments
Closed

Webpack 5 support #879

gurkerl83 opened this issue Nov 9, 2020 · 4 comments

Comments

@gurkerl83
Copy link

The current version of next-i18next (7.0.1) and its predecessors are not compatible with Webpack 5.

In the context of a Webpack based application development, two operating variants are distinguished, development and production.

When executing a build in the development profile, Webpack does not perform any optimisations, the build is successful.

In the production profile, Webpack applies advanced tweaking to reduce package sizes to a minimum. The static analysis used by Webpack identifies accessible paths to imported modules that are required by an application. The analysis takes into account dependencies not only of the first degree. Dependencies which themselves use other libraries as dependencies (transitive dependencies) become a problem in complex dependency chains.

First of all the error message during the execution in the production profile.

./node_modules/i18next-fs-backend/cjjs/formats/yaml.js
Cannot statically analyze 'require(..., ...)' in line 13

The dependency graph of next-i18next

next-i18next -> i18next-fs-backend -> js-yaml

In the module i18next-fs-backend artefacts are copied to the used library js-yaml and stored in the formats directory, initiated via an NPM script.

https://github.com/i18next/i18next-fs-backend/blob/569ce6c99c24e8ae4f82b47b164c6e74686b6b01/package.json#L63

Positions at which the problem is possibly caused.

  • js-yaml - Possibly the problem is in the library js-yaml, because an incompatible module format is output during assembly.
  • i18next-fs-backend - Possibly a wrong yaml.js (non-compliant file) is copied

In any case, the library i18next-fs-backend is imported into next-i18next as follows As the cause of the problem this can probably be excluded.

https://github.com/isaachinman/next-i18next/blob/01069e39a1c55e5df88de852c65198eb611abc09/src/create-client/browser.ts#L2

The error is probably not related to NextJs, older and newer versions were tested.

In summary it can be said that the problem and the above mentioned error output is probably not a bug in next-i18next itself, but is caused either by i18next-fs-backend or by js-yaml.

The next step would be to clarify on which level the problem occurs. This requires direct imports from i18next-fs-backend or js-yam.

Thx!

@isaachinman
Copy link
Contributor

Hey @gurkerl83, we're no longer importing i18next-http-backend at all in this package, and our import for i18next-fs-backend has been updated.

Can you let me know if you have any issues using webpack v5 on next-i18next v8?

@gurkerl83
Copy link
Author

@isaachinman I no longer use next-i18next, sry!

@isaachinman
Copy link
Contributor

No problem. What are you using these days?

@gurkerl83
Copy link
Author

@isaachinman I migrated my project to next-translate, https://github.com/vinissimus/next-translate/issues.

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

No branches or pull requests

2 participants