Skip to content

Commit 5f1136e

Browse files
format (#42)
1 parent 2cf0eb2 commit 5f1136e

File tree

12 files changed

+67
-61
lines changed

12 files changed

+67
-61
lines changed

packages/vite/src/node/optimizer/rolldownDepPlugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const externalTypes = [
4747
...KNOWN_ASSET_TYPES,
4848
]
4949

50-
5150
const optionalPeerDepNamespace = 'optional-peer-dep:'
5251
const browserExternalNamespace = 'browser-external:'
5352

@@ -328,4 +327,4 @@ export function rolldownCjsExternalPlugin(
328327
}
329328
},
330329
}
331-
}
330+
}

packages/vite/src/node/optimizer/scan.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import glob from 'fast-glob'
66
import type { Plugin } from 'rolldown'
77
import { scan } from 'rolldown/experimental'
88
import type { Loader } from 'esbuild'
9-
import { transform } from 'esbuild'
9+
import { transform } from 'esbuild'
1010
import colors from 'picocolors'
1111
import type { ResolvedConfig } from '..'
1212
import {
@@ -101,15 +101,13 @@ export function scanImports(config: ResolvedConfig): {
101101
if (!context || scanContext?.cancelled) {
102102
return { deps: {}, missing: {} }
103103
}
104-
return context
105-
.build()
106-
.then(() => {
107-
return {
108-
// Ensure a fixed order so hashes are stable and improve logs
109-
deps: orderedDependencies(deps),
110-
missing,
111-
}
112-
})
104+
return context.build().then(() => {
105+
return {
106+
// Ensure a fixed order so hashes are stable and improve logs
107+
deps: orderedDependencies(deps),
108+
missing,
109+
}
110+
})
113111
})
114112
.catch(async (e) => {
115113
// if (e.errors && e.message.includes('The build was canceled')) {
@@ -130,7 +128,7 @@ export function scanImports(config: ResolvedConfig): {
130128
// })
131129
// e.message = prependMessage + msgs.join('\n')
132130
// } else {
133-
e.message = prependMessage + e.message
131+
e.message = prependMessage + e.message
134132
// }
135133
throw e
136134
})
@@ -381,11 +379,12 @@ function rolldownScanPlugin(
381379
if (contents.includes('import.meta.glob')) {
382380
scripts[key] = {
383381
contents: await doTransformGlobImport(contents, p),
384-
loader
382+
loader,
385383
}
386384
} else {
387385
scripts[key] = {
388-
contents, loader
386+
contents,
387+
loader,
389388
}
390389
}
391390

@@ -418,10 +417,13 @@ function rolldownScanPlugin(
418417
return js
419418
}
420419

421-
const scripts: Record<string, {
422-
contents: string,
423-
loader: Loader,
424-
}> = {}
420+
const scripts: Record<
421+
string,
422+
{
423+
contents: string
424+
loader: Loader
425+
}
426+
> = {}
425427

426428
const ASSET_TYPE_RE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join('|')})$`)
427429

@@ -577,7 +579,7 @@ function rolldownScanPlugin(
577579
if (htmlTypesRE.test(id)) {
578580
return {
579581
code: await htmlTypeOnLoadCallback(id),
580-
moduleType: 'js'
582+
moduleType: 'js',
581583
}
582584
}
583585

@@ -598,7 +600,7 @@ function rolldownScanPlugin(
598600
if (loader !== 'js') {
599601
let tsconfigRaw
600602
const tsconfigResult = await loadTsconfigJsonForFile(
601-
path.join(config.root, '_dummy.js'),
603+
path.join(config.root, '_dummy.js'),
602604
)
603605
if (tsconfigResult.compilerOptions?.experimentalDecorators) {
604606
tsconfigRaw = { compilerOptions: { experimentalDecorators: true } }
@@ -622,7 +624,6 @@ function rolldownScanPlugin(
622624
}
623625
}
624626

625-
626627
/**
627628
* when using TS + (Vue + `<script setup>`) or Svelte, imports may seem
628629
* unused to esbuild and dropped in the build output, which prevents
@@ -664,4 +665,4 @@ function isScannable(id: string, extensions: string[] | undefined): boolean {
664665
extensions?.includes(path.extname(id)) ||
665666
false
666667
)
667-
}
668+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ import { getDepOptimizationConfig } from '../config'
5656
import type { ResolvedConfig } from '../config'
5757
import type { Plugin } from '../plugin'
5858
import { shouldExternalizeForSSR } from '../ssr/ssrExternal'
59-
import { getDepsOptimizer, optimizedDepInfoFromFile, optimizedDepNeedsInterop } from '../optimizer'
59+
import {
60+
getDepsOptimizer,
61+
optimizedDepInfoFromFile,
62+
optimizedDepNeedsInterop,
63+
} from '../optimizer'
6064
import {
6165
cleanUrl,
6266
unwrapId,

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,19 +533,23 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
533533
chunk.imports.forEach(addDeps)
534534
// Ensure that the css imported by current chunk is loaded after the dependencies.
535535
// So the style of current chunk won't be overwritten unexpectedly.
536-
getChunkMetadata(chunk.name)!.importedCss.forEach((file) => {
537-
deps.add(file)
538-
})
536+
getChunkMetadata(chunk.name)!.importedCss.forEach(
537+
(file) => {
538+
deps.add(file)
539+
},
540+
)
539541
}
540542
} else {
541543
const removedPureCssFiles =
542544
removedPureCssFilesCache.get(config)!
543545
const chunk = removedPureCssFiles.get(filename)
544546
if (chunk) {
545547
if (getChunkMetadata(chunk.name)!.importedCss.size) {
546-
getChunkMetadata(chunk.name)!.importedCss.forEach((file) => {
547-
deps.add(file)
548-
})
548+
getChunkMetadata(chunk.name)!.importedCss.forEach(
549+
(file) => {
550+
deps.add(file)
551+
},
552+
)
549553
hasRemovedPureCssChunk = true
550554
}
551555

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ export function metadataPlugin(): Plugin {
2828

2929
export function getChunkMetadata(name: string): ChunkMetadata | undefined {
3030
return chunkMetadataMap.get(name)
31-
}
31+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function preAliasPlugin(config: ResolvedConfig): Plugin {
5353
if (depsOptimizer.options.noDiscovery) {
5454
return
5555
}
56-
// TODO @underfin
56+
// TODO @underfin
5757
const resolved = await this.resolve(id, importer, {
5858
// ...options,
5959
// custom: { ...options.custom, 'vite:pre-alias': true },

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,25 @@ export function webWorkerPostPlugin(): Plugin {
187187
return {
188188
name: 'vite:worker-post',
189189
// TODO @underfin it's not unsupported yet
190-
// resolveImportMeta(property, { format }) {
191-
// // document is undefined in the worker, so we need to avoid it in iife
192-
// if (format === 'iife') {
193-
// // compiling import.meta
194-
// if (!property) {
195-
// // rollup only supports `url` property. we only support `url` property as well.
196-
// // https://github.com/rollup/rollup/blob/62b648e1cc6a1f00260bb85aa2050097bb4afd2b/src/ast/nodes/MetaProperty.ts#L164-L173
197-
// return `{
198-
// url: self.location.href
199-
// }`
200-
// }
201-
// // compiling import.meta.url
202-
// if (property === 'url') {
203-
// return 'self.location.href'
204-
// }
205-
// }
206-
207-
// return null
208-
// },
190+
// resolveImportMeta(property, { format }) {
191+
// // document is undefined in the worker, so we need to avoid it in iife
192+
// if (format === 'iife') {
193+
// // compiling import.meta
194+
// if (!property) {
195+
// // rollup only supports `url` property. we only support `url` property as well.
196+
// // https://github.com/rollup/rollup/blob/62b648e1cc6a1f00260bb85aa2050097bb4afd2b/src/ast/nodes/MetaProperty.ts#L164-L173
197+
// return `{
198+
// url: self.location.href
199+
// }`
200+
// }
201+
// // compiling import.meta.url
202+
// if (property === 'url') {
203+
// return 'self.location.href'
204+
// }
205+
// }
206+
207+
// return null
208+
// },
209209
}
210210
}
211211

packages/vite/src/node/server/sourcemap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export function applySourcemapIgnoreList(
126126
) {
127127
const sourcePath = map.sources[sourcesIndex]
128128
if (!sourcePath) continue
129-
129+
130130
const ignoreList = sourcemapIgnoreList(
131131
path.isAbsolute(sourcePath)
132132
? sourcePath
@@ -136,7 +136,7 @@ export function applySourcemapIgnoreList(
136136
if (logger && typeof ignoreList !== 'boolean') {
137137
logger.warn('sourcemapIgnoreList function must return a boolean.')
138138
}
139-
139+
140140
if (ignoreList && !x_google_ignoreList.includes(sourcesIndex)) {
141141
x_google_ignoreList.push(sourcesIndex)
142142
}

packages/vite/src/node/ssr/runtime/__tests__/fixtures/c.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
export { a as c } from './a'
42

53
import.meta.hot?.accept(() => {

packages/vite/src/node/ssr/runtime/__tests__/fixtures/d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
export { c as d } from './c'
42

53
import.meta.hot?.accept(() => {

0 commit comments

Comments
 (0)