MartinMalinda / vue-concurrency

A library for encapsulating asynchronous operations and managing concurrency for Vue and Composition API.
https://vue-concurrency.netlify.app/
MIT License
352 stars 15 forks source link

Vite 5 (Rollup 4) build issue #95

Closed ninoseki closed 11 months ago

ninoseki commented 11 months ago

Hello, first of all, thank you for creating this library. It helps me a lot.

Maybe this is an issue of CAF but let me report it. I tried to use vue-concurrency v4 with Vite 5. Then Vite 5 throws the following error.

$ npm run build
> vite build
...
vite v5.0.7 building for production...
...
"cancelToken" is not exported by "node_modules/caf/dist/esm/index.mjs", imported by "node_modules/vue-concurrency/dist/index.module.js".
file: /foo/bar/node_modules/vue-concurrency/dist/index.module.js:2:12
1: import{watch as n,computed as e,reactive as t,getCurrentInstance as r,effectScope as i,onBeforeUnmount as o,onServerP...
2: //# sourceMappingURL=index.module.js.map
               ^
error during build:
RollupError: "cancelToken" is not exported by "node_modules/caf/dist/esm/index.mjs", imported by "node_modules/vue-concurrency/dist/index.module.js".
    at error (file:///foo/bar/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    at Module.error (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:12738:16)
    at Module.traceVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:13175:29)
    at ModuleScope.findVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:11592:39)
    at FunctionScope.findVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:5897:38)
    at FunctionBodyScope.findVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:5897:38)
    at ChildScope.findVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:5897:38)
    at FunctionScope.findVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:5897:38)
    at FunctionBodyScope.findVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:5897:38)
    at ChildScope.findVariable (file:///foo/bar/node_modules/rollup/dist/es/shared/node-entry.js:5897:38)

Again it may be a CAF issue but vue-currency can have a workaround?

ninoseki commented 11 months ago

I found a solution. So let me memo it at here.

import { defineConfig } from "vite"

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      caf: "caf/caf"
    }
  }
})

works with Vite 5 (Rollup 4).