Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8596dfd
wip: bump rollup
sapphi-red Sep 30, 2023
b907e6e
wip: remove `acorn`/`acornInjectPlugins` option, remove additional op…
sapphi-red Sep 30, 2023
e6474ba
wip: replace "assertions" with "attributes"
sapphi-red Sep 30, 2023
00e0ece
wip: replace RollupWarning with RollupLog
sapphi-red Sep 30, 2023
0c488c7
wip: remove omit `moduleIds`
sapphi-red Sep 30, 2023
d9085f7
wip: call `this.addWatchFile` in vite:load-fallback plugin
sapphi-red Sep 30, 2023
4d49292
wip: remove utf8 BOM for now
sapphi-red Sep 30, 2023
f161d22
wip: use parse function from rollup
sapphi-red Sep 30, 2023
ddde37f
wip: bump rollup for plugin-legacy
sapphi-red Sep 30, 2023
49dafa0
wip: default of skipSelf is now true
sapphi-red Sep 30, 2023
176f6d5
wip: ignore rollup version mismatch type error
sapphi-red Sep 30, 2023
9f36ca3
wip: bump rollup
sapphi-red Oct 3, 2023
6b00745
wip: revert "wip: remove utf8 BOM for now"
sapphi-red Oct 3, 2023
632d3b0
wip: new hash algorithm
sapphi-red Oct 3, 2023
a3c750f
wip: new hash algorithm
sapphi-red Oct 3, 2023
ae0b4c4
wip: new hash algorithm
sapphi-red Oct 3, 2023
fa7a370
chore: merge main
sapphi-red Oct 5, 2023
e5bf794
chore: update rollup plugins
sapphi-red Oct 5, 2023
a274f82
wip: update rollup
sapphi-red Oct 5, 2023
19c2d76
wip: use parseAst function from rollup
sapphi-red Oct 5, 2023
60bb4fd
wip: remove ensureWatchedFile
sapphi-red Oct 5, 2023
1edfeff
wip: bump rollup to 4.0.0
sapphi-red Oct 5, 2023
dafc6d7
wip: use ^4.0.0 instead of 4.0.0
sapphi-red Oct 5, 2023
e2c9e8a
wip: add `addWatchFile` to assetPlugin
sapphi-red Oct 5, 2023
90f1344
wip: remove ensureWatchPlugin
sapphi-red Oct 5, 2023
924c4b0
wip: add migration guide
sapphi-red Oct 5, 2023
e56494e
wip: remove RollupParseFunc type
sapphi-red Oct 6, 2023
9ab9f61
wip: remove the tweak to workaround rollup/acorn inconsistency
sapphi-red Oct 6, 2023
522f77c
wip: update docs
sapphi-red Oct 6, 2023
c9eb9f3
wip: restore ensureWatchedFile in indexHtml.ts
sapphi-red Oct 6, 2023
342716a
chore: merge main
sapphi-red Oct 6, 2023
aae78cf
wip: new hash algorithm
sapphi-red Oct 6, 2023
c1fad36
wip: new hash algorithm
sapphi-red Oct 6, 2023
31ed8b1
chore: merge main
sapphi-red Oct 9, 2023
0728839
chore: merge main
sapphi-red Oct 11, 2023
3d081e3
chore: merge main
sapphi-red Oct 12, 2023
8915ca5
chore: bump vitepress
sapphi-red Oct 12, 2023
22d7bd9
chore: merge main
sapphi-red Oct 16, 2023
d5bd340
chore: bump rollup-plugin-license
sapphi-red Oct 16, 2023
72a4624
chore: bump rollup and magic-string
sapphi-red Oct 16, 2023
6a5d4dd
chore: merge main
sapphi-red Oct 16, 2023
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
Prev Previous commit
Next Next commit
wip: use parseAst function from rollup
  • Loading branch information
sapphi-red committed Oct 5, 2023
commit 19c2d76d5d2d97477823de29b0c39f79f366a62a
1 change: 1 addition & 0 deletions packages/vite/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function createNodeConfig(isProduction: boolean) {
external: [
'fsevents',
'lightningcss',
'rollup/parseAst',
...Object.keys(pkg.dependencies),
...(isProduction ? [] : Object.keys(pkg.devDependencies)),
],
Expand Down
29 changes: 3 additions & 26 deletions packages/vite/src/node/server/pluginContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ SOFTWARE.
import fs from 'node:fs'
import { join } from 'node:path'
import { performance } from 'node:perf_hooks'
import { rollup, VERSION as rollupVersion } from 'rollup'
import { VERSION as rollupVersion } from 'rollup'
import { parseAst as rollupParseAst } from 'rollup/parseAst'
import type {
AstNode,
AsyncPluginHooks,
Expand Down Expand Up @@ -152,28 +153,6 @@ export type RollupParseFunc = (
options?: { allowReturnOutsideFunction?: boolean },
) => AstNode

export const getRollupParseFunc = async (): Promise<RollupParseFunc> => {
let rollupParse!: RollupParseFunc
await rollup({
input: 'dummy',
plugins: [
{
name: 'get-parse',
resolveId(id) {
return id
},
load(id) {
return ''
},
transform(code, id) {
rollupParse = this.parse
},
},
],
})
return rollupParse
}

export async function createPluginContainer(
config: ResolvedConfig,
moduleGraph?: ModuleGraph,
Expand Down Expand Up @@ -297,8 +276,6 @@ export async function createPluginContainer(
}
}

const rollupParseFunc = await getRollupParseFunc()

// we should create a new context for each async hook pipeline so that the
// active plugin in that pipeline can be tracked in a concurrency-safe manner.
// using a class to make creating new contexts more efficient
Expand All @@ -317,7 +294,7 @@ export async function createPluginContainer(
}

parse(code: string, opts: any) {
return rollupParseFunc(code, opts)
return rollupParseAst(code, opts)
}

async resolve(
Expand Down
11 changes: 2 additions & 9 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import type {
import { extract_names as extractNames } from 'periscopic'
import { walk as eswalk } from 'estree-walker'
import type { RawSourceMap } from '@ampproject/remapping'
import { parseAst as rollupParseAst } from 'rollup/parseAst'
import type { TransformResult } from '../server/transformRequest'
import type { RollupParseFunc } from '../server/pluginContainer'
import { getRollupParseFunc } from '../server/pluginContainer'
import { combineSourcemaps } from '../utils'
import { isJSONRequest } from '../plugins/json'

Expand Down Expand Up @@ -62,8 +61,6 @@ async function ssrTransformJSON(
}
}

let rollupParseFunc: RollupParseFunc | undefined

async function ssrTransformScript(
code: string,
inMap: SourceMap | { mappings: '' } | null,
Expand All @@ -72,13 +69,9 @@ async function ssrTransformScript(
): Promise<TransformResult | null> {
const s = new MagicString(code)

if (!rollupParseFunc) {
rollupParseFunc = await getRollupParseFunc()
}

let ast: any
try {
ast = rollupParseFunc(code)
ast = rollupParseAst(code)
} catch (err) {
if (!err.loc || !err.loc.line) throw err
const line = err.loc.line
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"moduleResolution": "Bundler",
"strict": true,
"declaration": true,
"noImplicitOverride": true,
Expand Down