intlify / nuxt3

Nuxt 3 Module for vue-i18n-next

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nuxt 3 "intlify.vuei18n.options.mjs" does not provide an export named 'default'

sikeat7 opened this issue · comments

Hi! I'm my previous project and my fresh project got an error after I'm re-install node_modules. Is it a bug because my previous version used to work fine but after I deleted node_modules and re-install it back this error occurred. And fresh project also got this error. This is bug from Nuxt3 ? Thank you.

Screen Shot 2022-05-03 at 3 38 41 PM

commented

I think be both opened similar issues at the same time haha :D
Yeah, I've just got the same problem. Let's hope it'll be fixed soon

I think be both opened similar issues at the same time haha :D Yeah, I've just got the same problem. Let's hope it'll be fixed soon

Yes, I think it occurred while Nuxt3 updated some core. Hope Intlify's Team fix it soon.

Its working when nuxt version downgraded to rc1 release, hope this will be fixed for rc2 and future releases.

I've tried the rc1 release but to no avail. What does your package.json look like?

After forcing the versions in package.json I can confirm this has solved the issue

  "overrides": {
    "nuxi": "3.0.0-rc.1",
    "nuxt": "3.0.0-rc.1",
    "@nuxt/kit": "3.0.0-rc.1",
    "@nuxt/schema": "3.0.0-rc.1",
    "@nuxt/vite-builder": "3.0.0-rc.1"
  }

Any update about this issue? I can't work with the rc.2 version

@yacosta738

Any update about this issue? I can't work with the rc.2 version

There have been no updates since this issue started. I've tested RC.2 myself today and the problem still persist. I would recommend using the patch above, for now.

@FlyingWraptor thank you.

Same issue on freshly created project with "nuxt": "3.0.0-rc.3".

I found that the virtual template for intlify.vuei18n.options.mjs is not progressed by the unplugin loader https://github.com/intlify/nuxt3/blob/main/packages/nuxt3/src/loader.ts

But if you add write: true to addTemplate it does get found by the loader and modified by the transform.

For anyone who can use yarn patches i created one which adds the write: true.

package.json

{
  "resolutions": {
    "@intlify/nuxt3": "patch:@intlify/nuxt3@npm:0.2.1#.yarn/patches/@intlify-nuxt3-npm-0.2.1-56d98f6125.patch"
  }
}

.yarn/patches/@intlify-nuxt3-npm-0.2.1-56d98f6125.patch

diff --git a/dist/module.mjs b/dist/module.mjs
index cb993e5714666b1b93aa6262d85686d95cee2a16..f17706e9d407224e38f51bd2c3b02b94f475c0af 100644
--- a/dist/module.mjs
+++ b/dist/module.mjs
@@ -106,6 +106,7 @@ const IntlifyModule = defineNuxtModule({
     const localeResources = await resolveLocales(localePath) || [];
     addTemplate({
       filename: INTLIFY_VUEI18N_OPTIONS_VIRTUAL_FILENAME,
+      write: true,
       getContents: () => {
         return `${nuxt.options.dev ? "// 'vueI18n' option loading ..." : ""}`;
       }

One thing i was wondering is, why is there an extra loader which modfies the code when you could just add the logic to the getContents function. I tested it locally and it was working.

return `${nuxt.options.dev ? "// 'vueI18n' option loading ..." : ''}`

commented

I found that the virtual template for intlify.vuei18n.options.mjs is not progressed by the unplugin loader https://github.com/intlify/nuxt3/blob/main/packages/nuxt3/src/loader.ts

But if you add write: true to addTemplate it does get found by the loader and modified by the transform.

For anyone who can use yarn patches i created one which adds the write: true.

package.json

{
  "resolutions": {
    "@intlify/nuxt3": "patch:@intlify/nuxt3@npm:0.2.1#.yarn/patches/@intlify-nuxt3-npm-0.2.1-56d98f6125.patch"
  }
}

.yarn/patches/@intlify-nuxt3-npm-0.2.1-56d98f6125.patch

diff --git a/dist/module.mjs b/dist/module.mjs
index cb993e5714666b1b93aa6262d85686d95cee2a16..f17706e9d407224e38f51bd2c3b02b94f475c0af 100644
--- a/dist/module.mjs
+++ b/dist/module.mjs
@@ -106,6 +106,7 @@ const IntlifyModule = defineNuxtModule({
     const localeResources = await resolveLocales(localePath) || [];
     addTemplate({
       filename: INTLIFY_VUEI18N_OPTIONS_VIRTUAL_FILENAME,
+      write: true,
       getContents: () => {
         return `${nuxt.options.dev ? "// 'vueI18n' option loading ..." : ""}`;
       }

One thing i was wondering is, why is there an extra loader which modfies the code when you could just add the logic to the getContents function. I tested it locally and it was working.

return `${nuxt.options.dev ? "// 'vueI18n' option loading ..." : ''}`

Great work, I can confirm, this also works for me with Nuxt CLI v3.0.0-rc.3-27545866.cd37a21 - thank you!
Do you plan to do a pull request here: https://github.com/intlify/nuxt3?

@apss-pohl There has already been created a PR by @FlyingWraptor. Thank you for that!