Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Apr 9, 2024
1 parent 4cd3183 commit 46c8910
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/vite/src/node/plugins/assetImportMetaUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
const { environment } = this
if (
environment &&
!options?.ssr &&
// TODO: Should this be done only for the client or for any webCompatible environment?
environment.name === 'client' &&
id !== preloadHelperId &&
id !== CLIENT_ENTRY &&
code.includes('new URL') &&
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
if (isDirectCSSRequest(id)) {
return null
}
// server only
// server only, TODO: environment
if (options?.ssr) {
return modulesCode || `export default ${JSON.stringify(css)}`
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/preAlias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function preAliasPlugin(config: ResolvedConfig): Plugin {
}
}

// TODO: ?
// TODO: environment?
function optimizeAliasReplacementForSSR(
id: string,
optimizeDeps: DepOptimizationOptions,
Expand Down
9 changes: 7 additions & 2 deletions packages/vite/src/node/plugins/workerImportMetaUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
}
},

async transform(code, id, options) {
async transform(code, id) {
const { environment } = this
if (environment && !options?.ssr && isIncludeWorkerImportMetaUrl(code)) {
// TODO: environment, same as with assetImportMetaUrlPlugin
if (
environment &&
environment.name === 'client' &&
isIncludeWorkerImportMetaUrl(code)
) {
let s: MagicString | undefined
const cleanString = stripLiteral(code)
const workerImportMetaUrlRE =
Expand Down

0 comments on commit 46c8910

Please sign in to comment.