Skip to content

Commit

Permalink
fix: try fix esm on vue cli with vue2
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 15, 2021
1 parent a0e99fb commit 98185ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/v2/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'
import VueCompositionAPI from '@vue/composition-api/dist/vue-composition-api.esm.js'

function install(_vue) {
_vue = _vue || Vue
Expand All @@ -15,7 +15,7 @@ var Vue2 = Vue
var version = Vue.version

/**VCA-EXPORTS**/
export * from '@vue/composition-api'
export * from '@vue/composition-api/dist/vue-composition-api.esm.js'
/**VCA-EXPORTS**/

export {
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function updateVue2API() {
content = content.replace(
/\/\*\*VCA-EXPORTS\*\*\/[\s\S]+\/\*\*VCA-EXPORTS\*\*\//m,
`/**VCA-EXPORTS**/
export { ${exports.join(', ')} } from '@vue/composition-api'
export { ${exports.join(', ')} } from '@vue/composition-api/dist/vue-composition-api.esm.js'
/**VCA-EXPORTS**/`
)

Expand Down

3 comments on commit 98185ab

@leonardotessaroalves
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this change. my lib stopped work on nuxt.

compiling a cjs package, it'll always require this path 'dist/vue-composition-api.esm.js' .

src/index.js → dist/index.ssr.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
@vue/composition-api/dist/vue-composition-api.esm.js (imported by ../../node_modules/vue-demi/lib/index.mjs)
created dist/index.ssr.js in 9.1s
Done in 21.75s.

in Nuxt:

ERROR Failed to compile with 1 errors
This dependency was not found:

  • @vue/composition-api/dist/vue-composition-api.esm.js in ./node_modules/**/dist/index.ssr.js

@antfu
Copy link
Member Author

@antfu antfu commented on 98185ab Jul 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leonardotessaroalves try upgrade @vue/composition-api to v1.0.3

@masterkain
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.