Skip to content
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
15 changes: 8 additions & 7 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {

if (options.modernTargets) {
// Package is ESM only
const { default: browserslistToEsbuild } =
await import('browserslist-to-esbuild')
const { default: browserslistToEsbuild } = await import(
'browserslist-to-esbuild'
)
config.build.target = browserslistToEsbuild(options.modernTargets)
} else {
config.build.target = modernTargetsEsbuild
Expand Down Expand Up @@ -453,15 +454,15 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
}
}

const { rollupOptions } = config.build
const { output } = rollupOptions
const { rolldownOptions } = config.build
const { output } = rolldownOptions
if (Array.isArray(output)) {
rollupOptions.output = [
rolldownOptions.output = [
...output.map(createLegacyOutput),
...(genModern ? output : []),
]
} else {
rollupOptions.output = [
rolldownOptions.output = [
createLegacyOutput(output),
...(genModern ? [output || {}] : []),
]
Expand Down Expand Up @@ -858,7 +859,7 @@ async function buildPolyfillChunk(
minify,
assetsDir,
sourcemap,
rollupOptions: {
rolldownOptions: {
input: {
polyfills: polyfillId,
},
Expand Down
38 changes: 19 additions & 19 deletions packages/vite/src/node/__tests__/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('build', () => {
entry: ['foo.js', 'bar.js'],
formats: ['es'],
},
rollupOptions: {
rolldownOptions: {
external: 'external',
},
write: false,
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('resolveBuildOutputs', () => {
const resolveBuild = () => resolveBuildOutputs(outputs, libOptions, logger)

expect(resolveBuild).toThrowError(
/Entries in "build\.rollupOptions\.output" must specify "name"/,
/Entries in "build\.rolldownOptions\.output" must specify "name"/,
)
})

Expand All @@ -349,7 +349,7 @@ describe('resolveBuildOutputs', () => {
const resolveBuild = () => resolveBuildOutputs(outputs, libOptions, logger)

expect(resolveBuild).toThrowError(
/Entries in "build\.rollupOptions\.output" must specify "name"/,
/Entries in "build\.rolldownOptions\.output" must specify "name"/,
)
})
})
Expand Down Expand Up @@ -676,7 +676,7 @@ describe('resolveBuildOutputs', () => {
).toEqual([{ name: 'A' }])
expect(log.warn).toHaveBeenLastCalledWith(
colors.yellow(
`"build.lib.formats" will be ignored because "build.rollupOptions.output" is already an array format.`,
`"build.lib.formats" will be ignored because "build.rolldownOptions.output" is already an array format.`,
),
)
})
Expand All @@ -688,7 +688,7 @@ describe('resolveBuildOutputs', () => {
build: {
ssr: true,
ssrEmitAssets: true,
rollupOptions: {
rolldownOptions: {
input: {
index: '/entry',
},
Expand Down Expand Up @@ -716,7 +716,7 @@ describe('resolveBuildOutputs', () => {
build: {
ssr: true,
emitAssets: true,
rollupOptions: {
rolldownOptions: {
input: {
index: '/entry',
},
Expand Down Expand Up @@ -746,7 +746,7 @@ describe('resolveBuildOutputs', () => {
ssr: {
build: {
ssr: true,
rollupOptions: {
rolldownOptions: {
input: {
index: '/entry',
},
Expand All @@ -767,7 +767,7 @@ describe('resolveBuildOutputs', () => {
custom: {
build: {
ssr: true,
rollupOptions: {
rolldownOptions: {
input: {
index: '/entry',
},
Expand All @@ -788,7 +788,7 @@ test('default sharedConfigBuild true on build api', async () => {
logLevel: 'warn',
build: {
ssr: true,
rollupOptions: {
rolldownOptions: {
input: {
index: '/entry',
},
Expand Down Expand Up @@ -817,15 +817,15 @@ test.for([true, false])(
client: {
build: {
outDir: './dist/client',
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
},
ssr: {
build: {
outDir: './dist/server',
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
Expand All @@ -834,7 +834,7 @@ test.for([true, false])(
build: {
minify: true,
outDir: './dist/custom1',
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
Expand All @@ -843,7 +843,7 @@ test.for([true, false])(
build: {
minify: false,
outDir: './dist/custom2',
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
Expand Down Expand Up @@ -876,7 +876,7 @@ test('sharedConfigBuild and emitAssets', async () => {
build: {
outDir: './dist/client',
emitAssets: true,
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
Expand All @@ -885,7 +885,7 @@ test('sharedConfigBuild and emitAssets', async () => {
build: {
outDir: './dist/ssr',
emitAssets: true,
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
Expand All @@ -894,7 +894,7 @@ test('sharedConfigBuild and emitAssets', async () => {
build: {
outDir: './dist/custom',
emitAssets: true,
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
Expand Down Expand Up @@ -937,7 +937,7 @@ test.skip('adjust worker build error for worker.format', async () => {
await build({
root: resolve(__dirname, 'fixtures/worker-dynamic'),
build: {
rollupOptions: {
rolldownOptions: {
input: {
index: '/main.js',
},
Expand Down Expand Up @@ -968,7 +968,7 @@ describe('onRollupLog', () => {
logLevel: 'info',
build: {
write: false,
rollupOptions: {
rolldownOptions: {
...options,
logLevel: 'debug',
},
Expand Down Expand Up @@ -1115,7 +1115,7 @@ test('watch rebuild manifest', async (ctx) => {
environments: {
client: {
build: {
rollupOptions: {
rolldownOptions: {
input: '/entry.js',
},
},
Expand Down
18 changes: 9 additions & 9 deletions packages/vite/src/node/__tests__/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,26 +313,26 @@ describe('mergeConfig', () => {
).toThrowError('Cannot merge config in form of callback')
})

test('handles `rollupOptions`', () => {
test('handles `rolldownOptions`', () => {
const baseConfig = defineConfig({
build: {
rollupOptions: {
rolldownOptions: {
treeshake: false,
},
},
worker: {
rollupOptions: {
rolldownOptions: {
treeshake: false,
},
},
optimizeDeps: {
rollupOptions: {
rolldownOptions: {
treeshake: false,
},
},
ssr: {
optimizeDeps: {
rollupOptions: {
rolldownOptions: {
treeshake: false,
},
},
Expand All @@ -341,29 +341,29 @@ describe('mergeConfig', () => {

const newConfig = defineConfig({
build: {
rollupOptions: {
rolldownOptions: {
output: {
minifyInternalExports: true,
},
},
},
worker: {
rollupOptions: {
rolldownOptions: {
output: {
minifyInternalExports: true,
},
},
},
optimizeDeps: {
rollupOptions: {
rolldownOptions: {
output: {
minifyInternalExports: true,
},
},
},
ssr: {
optimizeDeps: {
rollupOptions: {
rolldownOptions: {
output: {
minifyInternalExports: true,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/__tests__/dev.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ViteDevServer } from '..'
import { promiseWithResolvers } from '../../shared/utils'

describe('resolveBuildEnvironmentOptions in dev', () => {
test('build.rollupOptions should not have input in lib', async () => {
test('build.rolldownOptions should not have input in lib', async () => {
const config = await resolveConfig(
{
build: {
Expand All @@ -17,7 +17,7 @@ describe('resolveBuildEnvironmentOptions in dev', () => {
'serve',
)

expect(config.build.rollupOptions).not.toHaveProperty('input')
expect(config.build.rolldownOptions).not.toHaveProperty('input')
})
})

Expand Down
8 changes: 4 additions & 4 deletions packages/vite/src/node/__tests__/environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('custom environment conditions', () => {
import.meta.dirname,
'fixtures/test-dep-conditions/dist/ssr',
),
rollupOptions: {
rolldownOptions: {
input: { index: '@vitejs/test-dep-conditions' },
},
},
Expand All @@ -50,7 +50,7 @@ describe('custom environment conditions', () => {
import.meta.dirname,
'fixtures/test-dep-conditions/dist/worker',
),
rollupOptions: {
rolldownOptions: {
input: { index: '@vitejs/test-dep-conditions' },
},
},
Expand All @@ -67,7 +67,7 @@ describe('custom environment conditions', () => {
import.meta.dirname,
'fixtures/test-dep-conditions/dist/custom1',
),
rollupOptions: {
rolldownOptions: {
input: { index: '@vitejs/test-dep-conditions' },
},
},
Expand All @@ -84,7 +84,7 @@ describe('custom environment conditions', () => {
import.meta.dirname,
'fixtures/test-dep-conditions/dist/custom1_2',
),
rollupOptions: {
rolldownOptions: {
input: { index: '@vitejs/test-dep-conditions' },
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/__tests__/plugins/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const getConfigWithPlugin = (
configFile: false,
server: { middlewareMode: true, ws: false },
optimizeDeps: { noDiscovery: true, include: [] },
build: { rollupOptions: { input }, write: false },
build: { rolldownOptions: { input }, write: false },
plugins,
logLevel: 'silent',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const buildProject = ({ format = 'es' as ModuleFormat } = {}) =>
logLevel: 'silent',
build: {
write: false,
rollupOptions: {
rolldownOptions: {
input: 'main.js',
output: {
format,
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe('file url', () => {
build: {
ssr: true,
outDir: 'dist/basic',
rollupOptions: {
rolldownOptions: {
input: { index: fileUrl.href },
},
},
Expand All @@ -300,7 +300,7 @@ describe('file url', () => {
build: {
ssr: true,
outDir: 'dist/virtual',
rollupOptions: {
rolldownOptions: {
input: { index: 'virtual:test-dep/static' },
},
},
Expand Down
Loading
Loading