Cimpress / cimpress-translations-webpack-plugin

Advanced Webpack integration with Cimpress' Translations service
4 stars 2 forks source link

Translation files not saved when not imported by any source file #1

Open Igrom opened 6 years ago

Igrom commented 6 years ago

Currently, the plugin works in a two-step process:

  1. Begin an asynchronous download of all translation files.
  2. Watch the dependency tree. If a translation file is imported by another file, await on the asynchronous download and save all translation files to path.

The problem with this flow is that if none of the translation files are imported by other files, the translation files are not saved to disk.

Wanting the translation files to be downloaded despite the rest of the project not being ready is a possible use case and the plugin should afford it as well.

The plugin should confirm that the download has been awaited on, and if not, await on it (likely at the end of the compilation process) and save the translation files.

A counterpoint is that, if the webpack project is built without importing the translation files, then they are not included in the bundle either way. Therefore the issue is discussable.


Steps to reproduce:

  1. Create a new webpack project.
  2. Configure the plugin.
  3. Do not import any of the translation files.
  4. Build the project.

Outcome: the translation files are not present.

ro-tex commented 6 years ago
  1. If the translation is not imported then it's not needed then it's OK not to download it. The issue here is that we've initiated a download which we don't need.

  2. I'm not sure how we're making sure a translation is not being imported. I mean not just in the current code but also in the future. Code like const translation = require('./translations/' + currentLang + '.json') might make it impossible to detect this with certainty. In this case we'd like to download and pack all available translations.