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

refactor: use .mjs for module by default #837

Merged
merged 1 commit into from
Oct 28, 2021
Merged

refactor: use .mjs for module by default #837

merged 1 commit into from
Oct 28, 2021

Conversation

antfu
Copy link
Member

@antfu antfu commented Oct 28, 2021

We believe it's a future-proofing move to use the explicit .mjs build for modules as it's the standard. Given the downstream libs like vue-demi and @vueuse/core are already moved to .mjs we think it's time for us to make the change. This will be released as v1.3.0.

Troubleshooting

.mjs can't resolve on Webpack 4

vueuse/vueuse#718

Nuxt
// nuxt.config.js

module.exports = {
  build: {
    extend (config) {
      config.module.rules.push({
        test: /\.mjs$/,
        include: /node_modules/,
        type: "javascript/auto"
      })
    }
  }
}
Vue CLI
// vue.config.js

module.exports = {
  configureWebpack: {
    module: {
      rules: [{
        test: /\.mjs$/,
        include: /node_modules/,
        type: "javascript/auto"
      }]
    }
  }
}

[vue-composition-api] must call Vue.use(VueCompositionAPI) before using any function

Make share you have only one version of @vue/composition-api installed and resolved to the same version.

Vite

vueuse/vue-demi#106 (comment)

resolve: {
  alias: [
    { find: /^@vue\/composition-api$/, replacement: '@vue/composition-api/dist/vue-composition-api.mjs' },
  ]
}
Webpack
resolve: {
  alias: [
    '@vue/composition-api$': '@vue/composition-api/dist/vue-composition-api.mjs'
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant