Skip to content

Feat: change rollup to rolldown #4434

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ArthurDarkstone
Copy link
Contributor

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.
⚠️ Slowing down new functions

Warning: Slowing down new functions

As the VueUse audience continues to grow, we have been inundated with an overwhelming number of feature requests and pull requests. As a result, maintaining the project has become increasingly challenging and has stretched our capacity to its limits. As such, in the near future, we may need to slow down our acceptance of new features and prioritize the stability and quality of existing functions. Please note that new features for VueUse may not be accepted at this time. If you have any new ideas, we suggest that you first incorporate them into your own codebase, iterate on them to suit your needs, and assess their generalizability. If you strongly believe that your ideas are beneficial to the community, you may submit a pull request along with your use cases, and we would be happy to review and discuss them. Thank you for your understanding.


Description

Additional context

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 26, 2024
@ArthurDarkstone ArthurDarkstone marked this pull request as draft December 26, 2024 07:31
@dosubot dosubot bot added the build tools label Dec 26, 2024
@ArthurDarkstone
Copy link
Contributor Author

ArthurDarkstone commented Dec 26, 2024

when using the '@rollup/plugin-json' plugin to convert json to esm, the above error will appear.

 vueuse  pnpm run build

> @vueuse/monorepo@12.2.0 build D:\Projects\github\forks\vueuse
> nr update && pnpm -r run build


> @vueuse/monorepo@12.2.0 update D:\Projects\github\forks\vueuse
> nr -C packages/metadata update && tsx scripts/update.ts


> @vueuse/metadata@12.2.0 update D:\Projects\github\forks\vueuse\packages\metadata
> tsx scripts/update.ts

No types dist found, run `npm run build:types` first.
Scope: 11 of 12 workspace projects
packages/metadata build$ rolldown --config=rolldown.config.ts
│ Error: Build failed with 8 errors:                                                                                                                                                                       
│ Error: [EXPORT_UNDEFINED_VARIABLE] Error: `metadata` is not declared in this file
│     ╭─[metadata.ts:13:10]
│     │
│  13 │ export { metadata, functions, packages, categories, functionNames, categoryNames, coreCategoryNames, addonCategoryNames, getFunction };
│     │          ────┬───
│     │              ╰─────
│ ────╯
│ Error: [EXPORT_UNDEFINED_VARIABLE] Error: `functions` is not declared in this file
│     ╭─[metadata.ts:13:20]
│     │
│  13 │ export { metadata, functions, packages, categories, functionNames, categoryNames, coreCategoryNames, addonCategoryNames, getFunction };                                                            
│     │                    ────┬────
│     │                        ╰────── 
│ ────╯
│ Error: [EXPORT_UNDEFINED_VARIABLE] Error: `packages` is not declared in this file
│     ╭─[metadata.ts:13:31]
│     │
│  13 │ export { metadata, functions, packages, categories, functionNames, categoryNames, coreCategoryNames, addonCategoryNames, getFunction };
│     │                               ────┬───
│     │                                   ╰─────
│ ────╯
│ Error: [EXPORT_UNDEFINED_VARIABLE] Error: `categories` is not declared in this file
│     ╭─[metadata.ts:13:41]
│     │
│  13 │ export { metadata, functions, packages, categories, functionNames, categoryNames, coreCategoryNames, addonCategoryNames, getFunction };
│     │                                         ─────┬────
│     │                                              ╰──────
│ ────╯
│ Error: [EXPORT_UNDEFINED_VARIABLE] Error: `functionNames` is not declared in this file
│     ╭─[metadata.ts:13:53]
│     │
│  13 │ export { metadata, functions, packages, categories, functionNames, categoryNames, coreCategoryNames, addonCategoryNames, getFunction };
│     │                                                     ──────┬──────
│     │                                                           ╰────────
│ ────╯
│ ...
│     at normalizeErrors (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/rolldown@1.0.0-beta.1_@babel+runtime@7.21.5/node_modules/rolldown/dist/shared/src-Bb3zZkPW.mjs:79:18)
│     at handleOutputErrors (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/rolldown@1.0.0-beta.1_@babel+runtime@7.21.5/node_modules/rolldown/dist/shared/src-Bb3zZkPW.mjs:230:34)
│     at transformToRollupOutput (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/rolldown@1.0.0-beta.1_@babel+runtime@7.21.5/node_modules/rolldown/dist/shared/src-Bb3zZkPW.mjs:224:2)
│     at RolldownBuild.write (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/rolldown@1.0.0-beta.1_@babel+runtime@7.21.5/node_modules/rolldown/dist/shared/src-Bb3zZkPW.mjs:2706:10)
│     at async bundleInner (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/rolldown@1.0.0-beta.1_@babel+runtime@7.21.5/node_modules/rolldown/dist/esm/cli.mjs:445:17)
│     at async bundleWithConfig (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/rolldown@1.0.0-beta.1_@babel+runtime@7.21.5/node_modules/rolldown/dist/esm/cli.mjs:365:6)
│     at async main (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/rolldown@1.0.0-beta.1_@babel+runtime@7.21.5/node_modules/rolldown/dist/esm/cli.mjs:2004:3) {
│   errors: [Getter/Setter]
│ }
└─ Failed in 3.2s at D:\Projects\github\forks\vueuse\packages\metadata
packages/shared build$ rolldown --config=rolldown.config.ts
└─ Running...
D:\Projects\github\forks\vueuse\packages\metadata:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @vueuse/metadata@12.2.0 build: `rolldown --config=rolldown.config.ts`
Exit status 1
 WARN   Local package.json exists, but node_modules missing, did you mean to install?

@ArthurDarkstone
Copy link
Contributor Author

found the root cause of the problem, the reason is the use of another plugin rollup-plugin-dts

rolldown/rolldown#3047

@ArthurDarkstone
Copy link
Contributor Author

solved.

rolldown is really fast !

 vueuse  pnpm run build

> @vueuse/monorepo@12.2.0 build D:\Projects\github\forks\vueuse
> nr update && pnpm -r run build


> @vueuse/monorepo@12.2.0 update D:\Projects\github\forks\vueuse
> nr -C packages/metadata update && tsx scripts/update.ts


> @vueuse/metadata@12.2.0 update D:\Projects\github\forks\vueuse\packages\metadata
> tsx scripts/update.ts

No types dist found, run `npm run build:types` first.
Scope: 11 of 12 workspace projects
packages/metadata build$ rolldown --config=rolldown.config.ts
│ <DIR>/index.mjs  chunk │ size: 74.57 kB
│ <DIR>/index.cjs  chunk │ size: 74.80 kB
│ <DIR>/index.d.cts  chunk │ size: 74.57 kB
│ <DIR>/index.d.mts  chunk │ size: 74.57 kB
│ <DIR>/index.d.ts  chunk │ size: 74.57 kB
│ ✔ Finished in 24.39 ms
└─ Done in 285ms
packages/shared build$ rolldown --config=rolldown.config.ts
│ <DIR>/index.mjs  chunk │ size: 42.61 kB
│ <DIR>/index.cjs  chunk │ size: 47.13 kB
│ <DIR>/index.iife.js  chunk │ size: 47.18 kB
│ <DIR>/index.iife.min.js  chunk │ size: 21.69 kB
│ <DIR>/index.d.cts  chunk │ size: 42.61 kB
│ <DIR>/index.d.mts  chunk │ size: 42.61 kB
│ <DIR>/index.d.ts  chunk │ size: 42.61 kB
│ ✔ Finished in 152.59 ms
└─ Done in 439ms
packages/electron build$ rolldown --config=rolldown.config.ts
│ <DIR>/index.mjs  chunk │ size: 4.01 kB
│ <DIR>/index.cjs  chunk │ size: 5.23 kB
│ <DIR>/index.d.cts  chunk │ size: 4.01 kB                                                                                                                                                                 
│ <DIR>/index.d.mts  chunk │ size: 4.01 kB                                                                                                                                                                 
│ <DIR>/index.d.ts  chunk │ size: 4.01 kB                                                                                                                                                                  
│ ✔ Finished in 28.50 ms                                                                                                                                                                                   
└─ Done in 316ms                                                                                                                                                                                           
packages/core build$ rolldown --config=rolldown.config.ts                                                                                                                                                  
│ <DIR>/index.mjs  chunk │ size: 213.64 kB                                                                                                                                                                 
│ <DIR>/index.cjs  chunk │ size: 227.46 kB
│ <DIR>/index.iife.js  chunk │ size: 227.49 kB                                                                                                                                                             
│ <DIR>/index.iife.min.js  chunk │ size: 107.81 kB                                                                                                                                                         
│ <DIR>/index.d.cts  chunk │ size: 213.60 kB                                                                                                                                                               
│ <DIR>/index.d.mts  chunk │ size: 213.60 kB                                                                                                                                                               
│ <DIR>/index.d.ts  chunk │ size: 213.60 kB                                                                                                                                                                
│ ✔ Finished in 274.31 ms                                                                                                                                                                                  
└─ Done in 552ms                                                                                                                                                                                           
packages/firebase build$ rolldown --config=rolldown.config.ts                                                                                                                                              
│ <DIR>/index.mjs  chunk │ size: 2.14 kB                                                                                                                                                                   
│ <DIR>/index.cjs  chunk │ size: 3.42 kB                                                                                                                                                                   
│ <DIR>/index.iife.js  chunk │ size: 3.51 kB                                                                                                                                                               
│ <DIR>/index.iife.min.js  chunk │ size: 1.64 kB                                                                                                                                                           
[1 lines collapsed]                                                                                                                                                                                        
│ <DIR>/index.d.mts  chunk │ size: 2.14 kB                                                                                                                                                                 
│ <DIR>/index.d.ts  chunk │ size: 2.14 kB                                                                                                                                                                  
│ <DIR>/useAuth.mjs  chunk │ size: 0.32 kB                                                                                                                                                                 
│ <DIR>/useAuth.cjs  chunk │ size: 1.33 kB                                                                                                                                                                 
[19 lines collapsed].js  chunk │ size: 1.39 kB                                                                                                                                                             
│ <DIR>/useFirestore.d.mts  chunk │ size: 1.44 kB
│ <DIR>/useFirestore.d.ts  chunk │ size: 1.44 kB
│ <DIR>/useRTDB.mjs  chunk │ size: 0.52 kB
│ <DIR>/useRTDB.cjs  chunk │ size: 1.61 kB
│ <DIR>/useRTDB.iife.js  chunk │ size: 1.68 kB
└─ Done in 720msiife.min.js  chunk │ size: 0.80 kB
│ <DIR>/useRTDB.d.cts  chunk │ size: 0.52 kB
│ <DIR>/useRTDB.d.mts  chunk │ size: 0.52 kB
│ <DIR>/useRTDB.d.ts  chunk │ size: 0.52 kB
│ ✔ Finished in 273.21 ms
│ <DIR>/index.iife.min.js  chunk │ size: 2.74 kB                                                                                                                                                           
│ <DIR>/index.d.cts  chunk │ size: 4.32 kBolldown.config.ts                                                                                                                                                
│ <DIR>/index.d.mts  chunk │ size: 4.32 kB                                                                                                                                                                 
│ <DIR>/index.d.ts  chunk │ size: 4.32 kB                                                                                                                                                                  
│ ✔ Finished in 97.95 mshunk │ size: 5.58 kB                                                                                                                                                               
└─ Done in 405ms                                                                                                                                                                                           
packages/router build$ rolldown --config=rolldown.config.ts                                                                                                                                                
│ <DIR>/index.mjs  chunk │ size: 4.14 kBkB                                                                                                                                                                 
│ <DIR>/index.cjs  chunk │ size: 5.51 kB                                                                                                                                                                   
│ <DIR>/index.iife.js  chunk │ size: 5.58 kB                                                                                                                                                               
│ <DIR>/index.iife.min.js  chunk │ size: 2.60 kB                                                                                                                                                           
│ <DIR>/index.d.cts  chunk │ size: 4.14 kBldown.config.ts
│ <DIR>/index.d.mts  chunk │ size: 4.14 kB
│ <DIR>/index.d.ts  chunk │ size: 4.14 kB
│ ✔ Finished in 63.50 ms
└─ Done in 396ms
packages/rxjs build$ rolldown --config=rolldown.config.ts
│ <DIR>/index.mjs  chunk │ size: 3.48 kB
│ <DIR>/index.cjs  chunk │ size: 4.83 kB
│ <DIR>/index.iife.js  chunk │ size: 4.89 kB
│ <DIR>/index.iife.min.js  chunk │ size: 2.11 kB
│ <DIR>/index.d.cts  chunk │ size: 3.48 kB
│ <DIR>/index.d.mts  chunk │ size: 3.48 kB
│ <DIR>/index.d.ts  chunk │ size: 3.48 kB
│ ✔ Finished in 60.99 ms
└─ Done in 493ms
packages/integrations build$ rolldown --config=rolldown.config.ts
[97 lines collapsed]                                                                                                                                                                                       
│ <DIR>/useSortable.iife.min.js  chunk │ size: 1.42 kB
│ <DIR>/useSortable.d.cts  chunk │ size: 1.73 kB
│ <DIR>/useSortable.d.mts  chunk │ size: 1.73 kB
│ <DIR>/useSortable.d.ts  chunk │ size: 1.73 kB
│ <DIR>/useSortable/component.cjs  chunk │ size: 3.40 kB
│ <DIR>/useSortable/component.mjs  chunk │ size: 2.31 kB
│ <DIR>/useSortable/component.d.cts  chunk │ size: 2.30 kB
│ <DIR>/useSortable/component.d.mts  chunk │ size: 2.30 kB
│ <DIR>/useSortable/component.d.ts  chunk │ size: 2.30 kB
│ ✔ Finished in 332.46 ms
└─ Done in 683ms                                                                                                                                                                                           
packages/components build$ rolldown --config=rolldown.config.ts                                                                                                                                            
│ <DIR>/index.mjs  chunk │ size: 63.26 kB                                                                                                                                                                  
│ <DIR>/index.cjs  chunk │ size: 68.15 kB                                                                                                                                                                  
│ <DIR>/index.iife.js  chunk │ size: 68.22 kB                                                                                                                                                              
│ <DIR>/index.iife.min.js  chunk │ size: 32.94 kB                                                                                                                                                          
│ <DIR>/index.d.cts  chunk │ size: 63.26 kB                                                                                                                                                                
│ <DIR>/index.d.mts  chunk │ size: 63.26 kB                                                                                                                                                                
│ <DIR>/index.d.ts  chunk │ size: 63.26 kB                                                                                                                                                                 
│ ✔ Finished in 162.59 ms                                                                                                                                                                                  
└─ Done in 454ms                                                                                                                                                                                           
packages/nuxt build$ rolldown --config=rolldown.config.ts                                                                                                                                                  
│ <DIR>/index.mjs  chunk │ size: 2.74 kB                                                                                                                                                                   
│ <DIR>/index.d.cts  chunk │ size: 2.74 kB
│ <DIR>/index.d.mts  chunk │ size: 2.74 kB
│ <DIR>/index.d.ts  chunk │ size: 2.74 kB
│ ✔ Finished in 15.47 ms
└─ Done in 290ms

@ArthurDarkstone ArthurDarkstone marked this pull request as ready for review December 26, 2024 10:08
@ArthurDarkstone ArthurDarkstone marked this pull request as draft December 26, 2024 11:08
@ArthurDarkstone
Copy link
Contributor Author

some error with doc build

 vueuse  pnpm run docs:build

> @vueuse/monorepo@12.2.0 docs:build D:\Projects\github\forks\vueuse
> nr update:full && vitepress build packages && nr build:redirects


> @vueuse/monorepo@12.2.0 update:full D:\Projects\github\forks\vueuse
> nr update && nr build:types


> @vueuse/monorepo@12.2.0 update D:\Projects\github\forks\vueuse
> nr -C packages/metadata update && tsx scripts/update.ts


> @vueuse/metadata@12.2.0 update D:\Projects\github\forks\vueuse\packages\metadata
> tsx scripts/update.ts


> @vueuse/monorepo@12.2.0 build:types D:\Projects\github\forks\vueuse
> tsc --emitDeclarationOnly


  vitepress v1.5.0

⠼ building client + server bundles...

--------
Twoslash error in code:
--------
import type { UseMouseEventExtractor } from '@vueuse/core'
import { useMouse, useParentElement } from '@vueuse/core'

const parentEl = useParentElement()

const extractor: UseMouseEventExtractor = event => (
  event instanceof Touch
    ? null
    : [event.offsetX, event.offsetY]
)

const { x, y, sourceType } = useMouse({ target: parentEl, type: extractor })
--------

x Build failed in 4.53s
✖ building client + server bundles...
build error:
[vite-plugin-pwa:build] 
## Errors were thrown in the sample, but not included in an error tag

These errors were not marked as being expected: 2305 7006.
Expected: // @errors: 2305 7006

Compiler Errors:

index.ts
  [2305] 14 - Module '"@vueuse/core"' has no exported member 'UseMouseEventExtractor'.
  [7006] 197 - Parameter 'event' implicitly has an 'any' type.
file: D:/Projects/github/forks/vueuse/packages/core/useMouse/index.md
[vite-plugin-pwa:build]
## Errors were thrown in the sample, but not included in an error tag

These errors were not marked as being expected: 2305 7006.
Expected: // @errors: 2305 7006

Compiler Errors:

index.ts
  [2305] 14 - Module '"@vueuse/core"' has no exported member 'UseMouseEventExtractor'.
  [7006] 197 - Parameter 'event' implicitly has an 'any' type.
file: D:/Projects/github/forks/vueuse/packages/core/useMouse/index.md
    at validateCodeForErrors (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/twoslash@0.2.12_typescript@5.7.2/node_modules/twoslash/dist/core.mjs:41:20)
    at twoslasher2 (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/twoslash@0.2.12_typescript@5.7.2/node_modules/twoslash/dist/core.mjs:346:7)
    at twoslasher (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/twoslash-vue@0.2.12_typescript@5.7.2/node_modules/twoslash-vue/dist/index.mjs:34:14)
    at Object.preprocess (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/@shikijs+twoslash@1.24.2_typescript@5.7.2/node_modules/@shikijs/twoslash/dist/core.mjs:1127:30)
    at Object.preprocess (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/@shikijs+vitepress-twoslash@1.24.4_@nuxt+kit@3.14.1592_magicast@0.3.5_rollup@4.29.1__typescript@5.7.2/node_modules/@shikijs/vitepress-twoslash/dist/index.mjs:226:34)
    at codeToHast (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/@shikijs+core@1.24.4/node_modules/@shikijs/core/dist/index.mjs:1151:37)
    at codeToHtml (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/@shikijs+core@1.24.4/node_modules/@shikijs/core/dist/index.mjs:1386:23)
    at Object.codeToHtml (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/@shikijs+core@1.24.4/node_modules/@shikijs/core/dist/index.mjs:1807:37)
    at Object.highlight (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/vitepress@1.5.0_@algolia+client-search@4.20.0_@types+node@22.10.2_jiti@2.4.0_postcss@8.4.49_s_sk4hwbg4aerggtm5hxxhytik6m/node_modules/vitepress/dist/node/chunk-DMuPggCS.js:35109:39)
    at default_rules.fence (file:///D:/Projects/github/forks/vueuse/node_modules/.pnpm/vitepress@1.5.0_@algolia+client-search@4.20.0_@types+node@22.10.2_jiti@2.4.0_postcss@8.4.49_s_sk4hwbg4aerggtm5hxxhytik6m/node_modules/vitepress/dist/node/chunk-DMuPggCS.js:24995:27)
 ELIFECYCLE  Command failed with exit code 1.

@ArthurDarkstone
Copy link
Contributor Author

it seems all keyword declare is missing

the dist diff of rolldown and rollup

image

only rollup has declare

image

@OrbisK
Copy link
Collaborator

OrbisK commented May 20, 2025

rolldown did some progress. @ArthurDarkstone Do you want to try it or should we investigate here?

@ArthurDarkstone
Copy link
Contributor Author

rolldown did some progress. @ArthurDarkstone Do you want to try it or should we investigate here?

sure. I will follow up on this. discuss wellcome

@ArthurDarkstone
Copy link
Contributor Author

since the code has not been updated for several months, the branch has deviated too much from the main branch code, so the latest main branch code is resynchronized and the feat-rolldown is developed based on it.

@ArthurDarkstone
Copy link
Contributor Author

using rollup-plugin-dts with rolldown may cause incompatibility, and the introduction of rolldown-plugin-dts solves this problem

@OrbisK
Copy link
Collaborator

OrbisK commented May 30, 2025

Are there still todos? Is there any way to support you or take on tasks?

@ArthurDarkstone
Copy link
Contributor Author

Are there still todos? Is there any way to support you or take on tasks?

Just now, every packages except the nuxt package can be built successfully. but when i change my os from 'win' to 'mac', i get errors when building

so, there are two questions now:

  1. fix nuxt package building problem
  2. check why there is an os problem

@ArthurDarkstone
Copy link
Contributor Author

Are there still todos? Is there any way to support you or take on tasks?

Just now, every packages except the nuxt package can be built successfully. but when i change my os from 'win' to 'mac', i get errors when building

so, there are two questions now:

  1. fix nuxt package building problem
  2. check why there is an os problem
  1. check whether the build product is consistent with the original rollup‘s product

@OrbisK
Copy link
Collaborator

OrbisK commented May 30, 2025

I can check the nuxt module 👍🏽

@ArthurDarkstone
Copy link
Contributor Author

ArthurDarkstone commented May 30, 2025

I can check the nuxt module 👍🏽

thanks. by now, i notice when I build, nuxt reports an error saying that the rolldown-beta.3 package is not found under node_modules/.pnpm, but I actually installed rolldown-beta.10

@OrbisK
Copy link
Collaborator

OrbisK commented May 30, 2025

thanks. by now, i notice when I build, nuxt reports an error saying that the rolldown-beta.3 package is not found under node_modules/.pnpm, but I actually installed rolldown-beta.10

Can you try to dedupe your deps? pnpm dedupe

@ArthurDarkstone
Copy link
Contributor Author

thanks. by now, i notice when I build, nuxt reports an error saying that the rolldown-beta.3 package is not found under node_modules/.pnpm, but I actually installed rolldown-beta.10

Can you try to dedupe your deps? pnpm dedupe

WechatIMG58 WechatIMG57

@ArthurDarkstone
Copy link
Contributor Author

ArthurDarkstone commented Jun 3, 2025

I can check the nuxt module 👍🏽

i think i solved this problem by adding this: 680565f

now, all packages be built successfully with rolldown !

https://app.netlify.com/projects/vueuse/deploys/683ea4c16985540008b24ecb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build tools size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants