Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"muggle-string": "^0.4.1",
"pathe": "^2.0.3",
"picomatch": "^4.0.3",
"rolldown-string": "^0.2.1",
"scule": "^1.3.0",
"tinyglobby": "^0.2.15",
"unplugin": "^2.3.11",
Expand Down Expand Up @@ -206,7 +207,7 @@
"rollup": "^4.53.3",
"semver": "^7.7.3",
"ts-expect": "^1.3.0",
"tsdown": "0.17.4",
"tsdown": "0.18.0",
"typescript": "^5.9.3",
"unplugin-auto-import": "^20.3.0",
"unplugin-vue-markdown": "^29.2.0",
Expand Down
21 changes: 16 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions src/data-loaders/auto-exports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createFilter } from 'unplugin-utils'
import type { Plugin } from 'vite'
import MagicString from 'magic-string'
import { withMagicString } from 'rolldown-string'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat -n src/data-loaders/auto-exports.ts | sed -n '1,10p'

Repository: posva/unplugin-vue-router

Length of output: 520


🏁 Script executed:

cat -n src/data-loaders/auto-exports.ts | sed -n '75,95p'

Repository: posva/unplugin-vue-router

Length of output: 708


🌐 Web query:

rolldown-string withMagicString API

💡 Result:

Short answer: there’s no widely used package named "rolldown-string". If you want the behavior (convert text files to modules) in Rolldown, implement a small plugin that uses MagicString — same pattern Rollup plugins use (transform/renderChunk returning code + sourcemap via MagicString). See MagicString docs and examples of Rollup plugins that do this.

Minimal example (conceptual):

  • import MagicString from 'magic-string'
  • in plugin transform(id, code) for matching files:
    • const s = new MagicString(code)
    • s.prepend("export default ")
    • s.append(";")
    • return { code: s.toString(), map: s.generateMap({ hires: true }) }

References:

  • MagicString (API & usage). [1]
  • Rolldown package/homepage (use same plugin hooks as Rollup). [2]
  • Example Rollup plugins using MagicString (pattern you can copy). [3]

Sources:
[1] Rich Harris — magic-string (GitHub README).
[2] rolldown package / homepage (npm).
[3] Example Rollup plugin code using MagicString (e.g., preserve-shebang / renderChunk).


rolldown-string package not found in standard documentation.

The withMagicString API from rolldown-string cannot be verified—this package does not appear in npm or standard documentation. The standard pattern for Rollup/Rolldown plugins requires explicit return of { code: s.toString(), map: s.generateMap({...}) }, not relying on automatic return value management. Either this is a custom/internal package that requires documentation, or the import path is incorrect.

🤖 Prompt for AI Agents
In src/data-loaders/auto-exports.ts around line 3, the import of withMagicString
from 'rolldown-string' is invalid/unpublished and the transform must explicitly
return { code, map }; replace the unknown import with a known approach (e.g.,
import MagicString from 'magic-string' or the correct helper package),
instantiate a MagicString for your source edits, and ensure the plugin/transform
returns an object like { code: s.toString(), map: s.generateMap({ hires: true })
}; if you intended a custom helper, add/update that module and document it and
ensure package.json includes the correct dependency.

import { findStaticImports, parseStaticImport } from 'mlly'
import { resolve } from 'pathe'
import { StringFilter, type UnpluginOptions } from 'unplugin'
Expand Down Expand Up @@ -79,21 +79,15 @@ export function AutoExportLoaders({
id: transformFilter,
},

handler(code) {
handler: withMagicString((s) => {
const code = s.toString()
const loadersToExports = extractLoadersToExport(code, filterPaths, root)

if (loadersToExports.length <= 0) return

const s = new MagicString(code)
s.append(
`\nexport const __loaders = [\n${loadersToExports.join(',\n')}\n];\n`
)

return {
code: s.toString(),
map: s.generateMap(),
}
},
}),
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, type Options } from 'tsdown'
import { defineConfig, type UserConfig } from 'tsdown'

export const commonOptions = {
format: ['cjs', 'esm'],
Expand All @@ -10,7 +10,7 @@ export const commonOptions = {
'@pinia/colada',
'pinia',
],
} satisfies Options
} satisfies UserConfig

export default defineConfig([
{
Expand Down
Loading