intlify / vue-i18n-composable

Composition API for vue-i18n in Vue 2.x
MIT License
44 stars 10 forks source link

Example not working #9

Open stephane303 opened 3 years ago

stephane303 commented 3 years ago

In the example folder, I did an npm install and npm dev:

ERROR  Failed to compile with 2 errors                                                                     
 error  in ./node_modules/vue-i18n-composable/dist/index.mjs

Can't import the named export 'computed' from non EcmaScript module (only default export is available)

 error  in ./node_modules/vue-i18n-composable/dist/index.mjs

Can't import the named export 'getCurrentInstance' from non EcmaScript module (only default export is available)

When doing the npm install I choose version 0.2.2 of vue-i18n-composable

caugner commented 3 years ago

@stephane303 I'm experiencing the same issue. Have you found a workaround, by any chance?

PS: Maybe these tsconfig.json settings are to restrictive:

https://github.com/intlify/vue-i18n-composable/blob/f35ee68712fcc1358a37b9d2f1632f58a06bccd8/tsconfig.json#L3-L4

In my project, we have them set to:

    "target": "ES6",
    "module": "ES2015",
caugner commented 3 years ago

cc @antfu: Writing import { useI18n } from 'vue-i18n-composable' like in the example, causes the following error:

Failed to compile.

./node_modules/vue-i18n-composable/dist/index.mjs 17:17-25
Can't import the named export 'computed' from non EcmaScript module (only default export is available)
caugner commented 3 years ago

FWIW I also tried these workarounds, without success:

stephane303 commented 3 years ago

@stephane303 I'm experiencing the same issue. Have you found a workaround, by any chance?

PS: Maybe these tsconfig.json settings are to restrictive:

https://github.com/intlify/vue-i18n-composable/blob/f35ee68712fcc1358a37b9d2f1632f58a06bccd8/tsconfig.json#L3-L4

In my project, we have them set to:

    "target": "ES6",
    "module": "ES2015",

My workaround has been to copy the file https://github.com/intlify/vue-i18n-composable/blob/master/src/index.ts directly in my project, it's dirty, but its working

kazupon commented 3 years ago

for example, you need to configure the following vue.config.js:

module.exports = {
  configureWebpack: (config) => {
    config.module.rules.push({
      test: /\.mjs$/,
      type: 'javascript/auto',
    })
  },
}