forked from vitejs/vite
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
Description
Describe the bug
When building with rolldown-vite and using advancedChunks as in the minimal reproduction, the compiled app throws the following error:
vendor.CqGkZehS.js:1 Uncaught ReferenceError: L is not defined
at vendor.CqGkZehS.js:1:235354
at vendor.CqGkZehS.js:1:410369This only happens when @geoman-io/leaflet-geoman-free is installed and imported.
The same project works correctly when using standard vite.
Minimal code to reproduce the error would be:
import L from 'leaflet'
import '@geoman-io/leaflet-geoman-free';Reproduction
https://github.com/twisterniq/rolldown-vite-uncaught-referenceerror-l-is-not-defined
Steps to reproduce
- Run
npm install - Run
npm run build - Run
npm run preview - See the error in the console.
System Info
System:
OS: Windows 11 10.0.26100
CPU: (12) x64 AMD Ryzen 5 7600X 6-Core Processor
Memory: 13.33 GB / 31.60 GB
Binaries:
Node: 24.11.0 - C:\nvm4w\nodejs\node.EXE
npm: 11.6.1 - C:\nvm4w\nodejs\npm.CMD
pnpm: 10.20.0 - C:\nvm4w\nodejs\pnpm.CMD
bun: 1.3.1 - C:\nvm4w\nodejs\bun.CMD
Browsers:
Chrome: 141.0.7390.123
Edge: Chromium (137.0.3296.83)
npmPackages:
rolldown-vite: 7.2.2Used Package Manager
npm
Logs
Click to expand!
2025-11-07T22:29:24.383Z vite:config config file loaded in 19.78ms
2025-11-07T22:29:24.385Z vite:env loading env files: [
'C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/.env',
'C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/.env.local',
'C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/.env.production',
'C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/.env.production.local'
]
2025-11-07T22:29:24.385Z vite:env env files loaded in 0.33ms
2025-11-07T22:29:24.385Z vite:env using resolved env: {}
2025-11-07T22:29:24.393Z vite:config using resolved config: {
base: './',
build: {
target: [ 'chrome107', 'edge107', 'firefox104', 'safari16' ],
polyfillModulePreload: true,
modulePreload: { polyfill: true },
outDir: 'dist',
assetsDir: 'assets',
assetsInlineLimit: 4096,
sourcemap: false,
terserOptions: {},
rolldownOptions: {
platform: 'browser',
output: {
advancedChunks: {
groups: [ { name: 'vendor', test: /[\\/]node_modules[\\/]/ } ]
}
}
},
commonjsOptions: { include: [ /node_modules/ ], extensions: [ '.js', '.cjs' ] },
dynamicImportVarsOptions: { warnOnError: true, exclude: [ /node_modules/ ] },
write: true,
emptyOutDir: null,
copyPublicDir: true,
license: false,
manifest: false,
lib: false,
ssrManifest: false,
ssrEmitAssets: false,
reportCompressedSize: true,
chunkSizeWarningLimit: 500,
watch: null,
cssCodeSplit: true,
minify: 'oxc',
rollupOptions: {
platform: 'browser',
output: {
advancedChunks: {
groups: [ { name: 'vendor', test: /[\\/]node_modules[\\/]/ } ]
}
}
},
ssr: false,
emitAssets: true,
createEnvironment: [Function: createEnvironment],
cssTarget: [ 'chrome107', 'edge107', 'firefox104', 'safari16' ],
cssMinify: true
},
worker: {
format: 'iife',
plugins: '() => plugins',
rollupOptions: {},
rolldownOptions: {}
},
optimizeDeps: {
include: [],
exclude: [],
needsInterop: [],
rollupOptions: [Getter/Setter],
extensions: [],
disabled: undefined,
holdUntilCrawlEnd: true,
force: false,
noDiscovery: false,
rolldownOptions: { resolve: { symlinks: true }, output: { topLevelVar: true } },
esbuildOptions: { preserveSymlinks: false }
},
ssr: {
target: 'node',
optimizeDeps: {
esbuildOptions: { preserveSymlinks: false },
include: [],
exclude: [],
needsInterop: [],
rollupOptions: { resolve: { symlinks: true }, output: { topLevelVar: true } },
extensions: [],
holdUntilCrawlEnd: true,
force: false,
noDiscovery: true,
rolldownOptions: { resolve: { symlinks: true }, output: { topLevelVar: true } }
},
external: [],
noExternal: [],
resolve: {
conditions: [ 'module', 'node', 'development|production' ],
externalConditions: [ 'node', 'module-sync' ]
}
},
environments: {
client: {
define: undefined,
resolve: {
externalConditions: [ 'node', 'module-sync' ],
extensions: [
'.mjs', '.js',
'.mts', '.ts',
'.jsx', '.tsx',
'.json'
],
dedupe: [],
noExternal: [],
external: [],
preserveSymlinks: false,
tsconfigPaths: false,
alias: [
{
find: /^\/?@vite\/env/,
replacement: '/@fs/C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/node_modules/vite/dist/client/env.mjs'
},
{
find: /^\/?@vite\/client/,
replacement: '/@fs/C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/node_modules/vite/dist/client/client.mjs'
}
],
mainFields: [ 'browser', 'module', 'jsnext:main', 'jsnext' ],
conditions: [ 'module', 'browser', 'development|production' ],
builtins: []
},
keepProcessEnv: false,
consumer: 'client',
optimizeDeps: {
include: [],
exclude: [],
needsInterop: [],
rollupOptions: [Getter/Setter],
extensions: [],
disabled: undefined,
holdUntilCrawlEnd: true,
force: false,
noDiscovery: false,
rolldownOptions: { resolve: { symlinks: true }, output: { topLevelVar: true } },
esbuildOptions: { preserveSymlinks: false }
},
dev: {
warmup: [],
sourcemap: { js: true },
sourcemapIgnoreList: [Function: isInNodeModules],
preTransformRequests: true,
createEnvironment: [Function: defaultCreateClientDevEnvironment],
recoverable: true,
moduleRunnerTransform: false
},
build: {
target: [ 'chrome107', 'edge107', 'firefox104', 'safari16' ],
polyfillModulePreload: true,
modulePreload: { polyfill: true },
outDir: 'dist',
assetsDir: 'assets',
assetsInlineLimit: 4096,
sourcemap: false,
terserOptions: {},
rolldownOptions: {
platform: 'browser',
output: {
advancedChunks: {
groups: [ { name: 'vendor', test: /[\\/]node_modules[\\/]/ } ]
}
}
},
commonjsOptions: { include: [ /node_modules/ ], extensions: [ '.js', '.cjs' ] },
dynamicImportVarsOptions: { warnOnError: true, exclude: [ /node_modules/ ] },
write: true,
emptyOutDir: null,
copyPublicDir: true,
license: false,
manifest: false,
lib: false,
ssrManifest: false,
ssrEmitAssets: false,
reportCompressedSize: true,
chunkSizeWarningLimit: 500,
watch: null,
cssCodeSplit: true,
minify: 'oxc',
rollupOptions: {
platform: 'browser',
output: {
advancedChunks: {
groups: [ { name: 'vendor', test: /[\\/]node_modules[\\/]/ } ]
}
}
},
ssr: false,
emitAssets: true,
createEnvironment: [Function: createEnvironment],
cssTarget: [ 'chrome107', 'edge107', 'firefox104', 'safari16' ],
cssMinify: true
},
plugins: [
{
name: 'vite:watch-package-data',
buildStart: [Function: buildStart],
buildEnd: [Function: buildEnd],
watchChange: [Function: watchChange]
},
BuiltinPlugin {
name: 'builtin:alias',
_options: {
entries: [
{
find: /^\/?@vite\/env/,
replacement: '/@fs/C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/node_modules/vite/dist/client/env.mjs'
},
{
find: /^\/?@vite\/client/,
replacement: '/@fs/C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error/node_modules/vite/dist/client/client.mjs'
}
]
}
},
BuiltinPlugin {
name: 'builtin:module-preload-polyfill',
_options: { isServer: false }
},
{
name: 'vite:resolve-builtin:get-environment',
buildStart: [Function: buildStart],
perEnvironmentStartEndDuringDev: true
},
BuiltinPlugin {
name: 'builtin:vite-resolve',
_options: {
resolveOptions: {
isBuild: true,
isProduction: true,
asSrc: true,
preferRelative: false,
isRequire: undefined,
root: 'C:/Users/twist/Documents/Dev/rolldown-vite-chunks-error',
scan: false,
mainFields: [ 'browser', 'module', 'jsnext:main', 'jsnext', 'main' ],
conditions: [ 'module', 'browser', 'development|production' ],
externalConditions: [ 'node', 'module-sync' ],
extensions: [
'.mjs', '.js',
'.mts', '.ts',
'.jsx', '.tsx',
'.json'
],
tryIndex: true,
tryPrefix: undefined,
preserveSymlinks: false,
tsconfigPaths: false
},
environmentConsumer: 'client',
environmentName: 'client',
builtins: [],
external: [],
noExternal: [],
dedupe: [],
legacyInconsistentCjsInterop: undefined,
finalizeBareSpecifier: undefined,
finalizeOtherSpecifiers: undefined,
resolveSubpathImports: [Function: resolveSubpathImports]
},
load: [AsyncFunction (anonymous)],
resolveId: [AsyncFunction (anonymous)],
transform: [AsyncFunction (anonymous)],
watchChange: [AsyncFunction (anonymous)],
perEnvironmentWatchChangeDuringDev: true
},
{
name: 'vite:html-inline-proxy',
resolveId: {
filter: { id: /[?&]html-proxy\b/ },
handler: [Function: handler]
},
load: {
filter: { id: /[?&]html-proxy\b/ },
handler: [Function: handler]
}
},
{
name: 'vite:css',
buildStart: [Function: buildStart],
buildEnd: [Function: buildEnd],
load: {
filter: {
id: /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
},
handler: [AsyncFunction: handler]
},
transform: {
filter: {
id: {
include: /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/,
exclude: [
/[?&]commonjs-proxy/,
/[?&](?:worker|sharedworker|raw|url)\b/
]
}
},
handler: [AsyncFunction: handler]
}
},
BuiltinPlugin {
name: 'builtin:transform',
_options: {
include: [ /\.(m?ts|[jt]sx)$/ ],
exclude: [ /\.js$/ ],
jsxRefreshInclude: undefined,
jsxRefreshExclude: undefined,
isServerConsumer: false,
jsxInject: undefined,
transformOptions: { jsx: { development: false }, sourcemap: true }
}
},
BuiltinPlugin {
name: 'builtin:json',
_options: { namedExports: true, stringify: 'auto', minify: true },
load: [AsyncFunction (anonymous)],
resolveId: [AsyncFunction (anonymous)],
transform: [AsyncFunction (anonymous)],
watchChange: [AsyncFunction (anonymous)]
},
BuiltinPlugin {
name: 'builtin:wasm-helper',
_options: { decodedBase: './' }
},
{
name: 'vite:worker',
buildStart: [Function: buildStart],
load: {
filter: { id: /(?:\?|&)(worker|sharedworker)(?:&|$)/ },
handler: [AsyncFunction: handler]
},
transform: {
filter: { id: /(?:\?|&)worker_file&type=(\w+)(?:&|$)/ },
handler: [AsyncFunction: handler]
},
renderChunk: [Function: renderChunk],
generateBundle: [Function: generateBundle],
watchChange: [Function: watchChange]
},
{
name: 'vite:asset',
perEnvironmentStartEndDuringDev: true,
buildStart: [Function: buildStart],
resolveId: {
filter: {
id: [
/(\?|&)url(?:&|$)/,
/\.(apng|bmp|png|jpe?g|jfif|pjpeg|pjp|gif|svg|ico|webp|avif|cur|jxl|mp4|webm|ogg|mp3|wav|flac|aac|opus|mov|m4a|vtt|woff2?|eot|ttf|otf|webmanifest|pdf|txt)(\?.*)?$/i
]
},
handler: [Function: handler]
},
load: {
filter: {
id: {
include: [
/(\?|&)raw(?:&|$)/,
/(\?|&)url(?:&|$)/,
/\.(apng|bmp|png|jpe?g|jfif|pjpeg|pjp|gif|svg|ico|webp|avif|cur|jxl|mp4|webm|ogg|mp3|wav|flac|aac|opus|mov|m4a|vtt|woff2?|eot|ttf|otf|webmanifest|pdf|txt)(\?.*)?$/i
],
exclude: /^\0/
}
},
handler: [AsyncFunction: handler]
},
renderChunk: [Function: renderChunk],
generateBundle: [Function: generateBundle]
},
BuiltinPlugin {
name: 'builtin:wasm-fallback',
_options: undefined,
load: [AsyncFunction (anonymous)],
resolveId: [AsyncFunction (anonymous)],
transform: [AsyncFunction (anonymous)],
watchChange: [AsyncFunction (anonymous)]
},
{ name: 'vite:define', options: [Function: options] },
{
name: 'vite:css-post',
renderStart: [Function: renderStart],
transform: {
filter: {
id: {
include: /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/,
exclude: [
/[?&]commonjs-proxy/,
/[?&](?:worker|sharedworker|raw|url)\b/
]
}
},
handler: [AsyncFunction: handler]
},
renderChunk: [AsyncFunction: renderChunk],
augmentChunkHash: [Function: augmentChunkHash],
generateBundle: [AsyncFunction: generateBundle]
},
{
name: 'vite:build-html',
transform: {
filter: { id: /\.html$/ },
handler: [AsyncFunction: handler]
},
generateBundle: [AsyncFunction: generateBundle]
},
{
name: 'vite:worker-import-meta-url',
applyToEnvironment: [Function: applyToEnvironment],
transform: {
filter: {
code: /new\s+(?:Worker|SharedWorker)\s*\(\s*new\s+URL.+?import\.meta\.url/s
},
handler: [AsyncFunction: handler]
}
},
{
name: 'vite:asset-import-meta-url',
applyToEnvironment: [Function: applyToEnvironment],
transform: {
filter: {
id: {
exclude: [
/^Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs and the Rolldown-related guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.