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

'unplugin-vue-i18n/messages' is imported by nuxt/dist/server but could not be resolved – treating it as an external dependency. #1085

Closed
5 tasks done
jonmes opened this issue Jul 25, 2022 · 2 comments
Labels
Status: Review Needed Request for review comments

Comments

@jonmes
Copy link

jonmes commented Jul 25, 2022

Reporting a bug?

Could not resolve import
"@intlify/unplugin-vue-i18n/messages" in ...nuxt/dist/server/server.mjs
using exports defined in /node_modules/@intlify/unplugin-vue-i18n/package.json.
'@intlify/unplugin-vue-i18n/messages' is imported by .nuxt/dist/server/server.mjs, but could not be resolved – treating it as an external dependency.

Expected behavior

In dev mode @intlify/unplugin-vue-i18n/messages the package automatically imports the messages created in the locales folder, but while building a ssr in nuxt 3 the builder couldn't resolve the messages file, and treating it as an external dependency.
I was expecting that the builder would import @intlify/unplugin-vue-i18n/messages, so I can find the messages in built ssr file.

Reproduction

Link to github repo that show how i implement it. to see the bug just uncomment this lineGitHub

System Info

### Package
{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
  "devDependencies": {
    "@intlify/unplugin-vue-i18n": "^0.4.0",
    "nuxt": "3.0.0-rc.5",
    "vue-i18n": "^9.1.10"
  },
  "dependencies": {
    "@vee-validate/i18n": "^4.6.2",
    "petite-vue-i18n": "^9.2.0-beta.39",
    "vee-validate": "^4.6.2"
  }
}


### nuxt.config.ts
import { defineNuxtConfig } from "nuxt";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "url";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  vite: {
    plugins: [
      // VueI18nPlugin.vite({ /* options */ }),
      VueI18nPlugin({
        include: [
          resolve(dirname(fileURLToPath(import.meta.url)), "./locales/*.json"),
        ],
      }),
    ],
  },
});

Screenshot

image

Additional context

No response

Validations

@jonmes jonmes added the Status: Review Needed Request for review comments label Jul 25, 2022
@jonmes jonmes changed the title '@intlify/unplugin-vue-i18n/messages' is imported by .nuxt/dist/server/_blog_.55070800.js, but could not be resolved – treating it as an external dependency 'unplugin-vue-i18n/messages' is imported by nuxt/dist/server but could not be resolved – treating it as an external dependency. Jul 25, 2022
@kazupon
Copy link
Member

kazupon commented Jul 25, 2022

Duplicated this issue
intlify/bundle-tools#145

Thank you for your reporting!

@kazupon kazupon closed this as completed Jul 25, 2022
@jonmes
Copy link
Author

jonmes commented Jul 26, 2022

my bad I haven't properly configured the build transpiler.
build: { transpile: ["@intlify/unplugin-vue-i18n"], },
now it generates perfectly using the code above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

No branches or pull requests

2 participants