Skip to content
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

chore: vite v6 experiment #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"rollup": "^4.14.3",
"typedarray": "npm:@nolyfill/typedarray@latest",
"util.promisify": "npm:@nolyfill/util.promisify@latest",
"vite": "^5.2.9",
"vite": "6.0.0-alpha.3",
"which-typed-array": "npm:@nolyfill/which-typed-array@latest"
}
},
Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/modes/global/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>
let viteConfig: ResolvedConfig

// use maps to differentiate multiple build. using outDir as key
let transformContext: PluginContext | undefined
const cssPostPlugins = new Map<string | undefined, Plugin | undefined>()
const cssPlugins = new Map<string | undefined, Plugin | undefined>()

Expand All @@ -40,7 +41,7 @@ export function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>
if (!cssPlugins.get(dir) || !postcss)
return css
// @ts-expect-error without this context absolute assets will throw an error
const result = await cssPlugins.get(dir).transform.call(ctx, css, id)
const result = await cssPlugins.get(dir).transform.call(transformContext ?? ctx, css, id)
if (!result)
return css
if (typeof result === 'string')
Expand Down Expand Up @@ -76,6 +77,8 @@ export function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>
lastResult = undefined
},
transform(code, id) {
// eslint-disable-next-line ts/no-this-alias
transformContext = this
if (filter(code, id))
tasks.push(extract(code, id))
return null
Expand Down
Loading