Skip to content

Commit 5c0dddb

Browse files
authored
feat: update rolldown and support resolveSubpathImports for oxcResolvePlugin (#287)
1 parent 6058493 commit 5c0dddb

File tree

4 files changed

+72
-101
lines changed

4 files changed

+72
-101
lines changed

packages/vite/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"lightningcss": "^1.30.1",
8787
"picomatch": "^4.0.2",
8888
"postcss": "^8.5.6",
89-
"rolldown": "1.0.0-beta.21",
89+
"rolldown": "1.0.0-beta.23",
9090
"tinyglobby": "^0.2.14"
9191
},
9292
"optionalDependencies": {
@@ -98,7 +98,7 @@
9898
"@jridgewell/trace-mapping": "^0.3.25",
9999
"@oxc-project/types": "0.75.0",
100100
"@polka/compression": "^1.0.0-next.25",
101-
"@rolldown/pluginutils": "1.0.0-beta.21",
101+
"@rolldown/pluginutils": "1.0.0-beta.23",
102102
"@rollup/plugin-alias": "^5.1.1",
103103
"@rollup/plugin-commonjs": "^28.0.6",
104104
"@rollup/plugin-dynamic-import-vars": "2.1.4",

packages/vite/src/node/plugins/resolve.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ export function oxcResolvePlugin(
227227
...(!resolveOptions.isBuild
228228
? [optimizerResolvePlugin(resolveOptions)]
229229
: []),
230-
importGlobSubpathImportsResolvePlugin(resolveOptions),
231230
...perEnvironmentOrWorkerPlugin(
232231
'vite:resolve-builtin',
233232
overrideEnvConfig,
@@ -344,6 +343,11 @@ export function oxcResolvePlugin(
344343
)
345344
return newResolvedId === resolvedId ? undefined : newResolvedId
346345
},
346+
resolveSubpathImports(id, importer, isRequire, scan) {
347+
options.isRequire = resolveOptions.isRequire ?? isRequire
348+
options.scan = scan
349+
return resolveSubpathImports(id, importer, options)
350+
},
347351
})
348352
},
349353
),
@@ -448,39 +452,6 @@ function optimizerResolvePlugin(
448452
}
449453
}
450454

451-
function importGlobSubpathImportsResolvePlugin(
452-
resolveOptions: ResolvePluginOptionsWithOverrides,
453-
): Plugin {
454-
const { root } = resolveOptions
455-
456-
return {
457-
name: 'vite:resolve-import-glob-subpath-imports',
458-
resolveId: {
459-
filter: {
460-
id: {
461-
include: [/^#/],
462-
},
463-
},
464-
handler(id, importer, resolveOpts) {
465-
const options: InternalResolveOptions = {
466-
isRequire: resolveOpts.kind === 'require-call',
467-
...this.environment.config.resolve,
468-
...resolveOptions,
469-
scan: resolveOpts.scan ?? resolveOptions.scan,
470-
}
471-
options.preferRelative ||= importer?.endsWith('.html')
472-
473-
if (resolveOpts.custom?.['vite:import-glob']?.isSubImportsPattern) {
474-
const resolvedImports = resolveSubpathImports(id, importer, options)
475-
if (resolvedImports) {
476-
return normalizePath(path.join(root, resolvedImports))
477-
}
478-
}
479-
},
480-
},
481-
}
482-
}
483-
484455
export function resolvePlugin(
485456
resolveOptions: ResolvePluginOptionsWithOverrides,
486457
): Plugin {

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"convert-source-map": "^2.0.0",
1111
"css-color-names": "^1.0.1",
1212
"kill-port": "^1.6.1",
13-
"rolldown": "1.0.0-beta.21"
13+
"rolldown": "1.0.0-beta.23"
1414
}
1515
}

0 commit comments

Comments
 (0)