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

fix: message compiler tries to parse node_module dependency #168

Closed
4 tasks done
dargmuesli opened this issue Aug 30, 2022 · 3 comments
Closed
4 tasks done

fix: message compiler tries to parse node_module dependency #168

dargmuesli opened this issue Aug 30, 2022 · 3 comments
Assignees
Labels

Comments

@dargmuesli
Copy link

Reporting a bug?

Using @intlify/unplugin-vue-i18n and having html-to-text on a Nuxt page, as given in the reproduction codesandbox, yields an error. Diving deeper reveals that a source file is tried to be loaded, which does not contain translations, but special characters. It ends in:

...
♣            
♣                                                                                                                                                                                                                                                                                                                                                             
:                                                                                                                                                                                                                                                                                                                                                             
∷                                                                                                                                                                                                                                                                                                                                                             
⩴           
≔                                                                                                                                                                                                                                                                                                                                                             
≔                                                                                                                                                                                                                                                                                                                                                             
,                                                                                                                                                                                                                                                                                                                                                             
@

To me this looks very much like coming from https://yarnpkg.com/package/entities or similar.

Expected behavior

The bundler only tries to compile actual translations, not special characters that seem to come out of node_modules.

Reproduction

Run a yarn build over here: https://codesandbox.io/s/i18n-html-to-text-urt22w?file=/pages/index.vue
Try commenting the htmlToText usage out and the basic string usage in and see that the error vanishes.
Note: the error message there is obfuscated due to intlify/vue-i18n#1142.

Issue Package

unplugin-vue-i18n

System Info

System:
    OS: Linux 5.13 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
    Memory: 43.03 GB / 62.60 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  npmPackages:
    vue: 3.2.37 => 3.2.37
    vue-i18n: 9.2.2 => 9.2.2

Screenshot

No response

Additional context

Maybe the node_modules folder can be ignored?

Validations

  • Read the Contributing Guidelines.
  • Read the README
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion.
@dargmuesli
Copy link
Author

My suggestion for a fix is to set the include option's default to exclude node_modules.
A workaround is to set the default yourself:

  vite: {
    plugins: [
      VueI18nPlugin({
        include: '!' + resolve(dirname(fileURLToPath(import.meta.url)), './node_modules/**'),
      }),
    ],
  },

It'd take me some time to figure out how to implement that default. If you think my suggestion above is fine, @kazupon, it'd be great if you could implement it! 🥳 Otherwise just tell that this is open for grabs and whoever gets time to work on it first, does so :)


A workaround would be to just set the include option to include all source files, e.g.

  vite: {
    plugins: [
      VueI18nPlugin({
        include: resolve(dirname(fileURLToPath(import.meta.url)), './locales/**'),
      }),
    ],
  },

Copy link
Member

kazupon commented Sep 20, 2022

I think It would be nice to support an exclude option, like rollup's @rollup/json plugin.
https://github.com/rollup/plugins/tree/master/packages/json#exclude

If we don’t specify it, it would be nice to exclude the default node_modules.

@kazupon kazupon self-assigned this Sep 20, 2022
@kazupon kazupon added Package: unplugin-vue-i18n Status: PR Welcome Welcome to Pull Request Status: Proposal Request for comments and removed Status: Review Needed Request for review comments labels Sep 20, 2022 — with Volta.net
Copy link
Member

kazupon commented Nov 12, 2022

I think this issue is fixed with #195
Thanks!

@kazupon kazupon closed this as completed Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants