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

feat!: set esbuild default charset to utf8 #10753

Merged
merged 4 commits into from Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/vite/src/node/__tests__/plugins/esbuild.spec.ts
Expand Up @@ -17,6 +17,7 @@ describe('resolveEsbuildTranspileOptions', () => {
'es'
)
expect(options).toEqual({
charset: 'utf8',
target: 'es2020',
format: 'esm',
keepNames: true,
Expand Down Expand Up @@ -59,6 +60,7 @@ describe('resolveEsbuildTranspileOptions', () => {
'es'
)
expect(options).toEqual({
charset: 'utf8',
target: undefined,
format: 'esm',
keepNames: true,
Expand Down Expand Up @@ -88,6 +90,7 @@ describe('resolveEsbuildTranspileOptions', () => {
'es'
)
expect(options).toEqual({
charset: 'utf8',
target: 'es2020',
format: 'esm',
keepNames: true,
Expand Down Expand Up @@ -119,6 +122,7 @@ describe('resolveEsbuildTranspileOptions', () => {
'es'
)
expect(options).toEqual({
charset: 'utf8',
target: undefined,
format: 'esm',
keepNames: true,
Expand Down Expand Up @@ -150,6 +154,7 @@ describe('resolveEsbuildTranspileOptions', () => {
'cjs'
)
expect(options).toEqual({
charset: 'utf8',
target: undefined,
format: 'cjs',
keepNames: true,
Expand Down Expand Up @@ -180,6 +185,7 @@ describe('resolveEsbuildTranspileOptions', () => {
'es'
)
expect(options).toEqual({
charset: 'utf8',
target: undefined,
format: 'esm',
keepNames: true,
Expand Down Expand Up @@ -214,6 +220,7 @@ describe('resolveEsbuildTranspileOptions', () => {
'cjs'
)
expect(options).toEqual({
charset: 'utf8',
target: undefined,
format: 'cjs',
keepNames: true,
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -612,6 +612,7 @@ export async function runOptimizeDeps(
ignoreAnnotations: !isBuild,
metafile: true,
plugins,
charset: 'utf8',
...esbuildOptions,
supported: {
'dynamic-import': true,
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/node/plugins/esbuild.ts
Expand Up @@ -180,6 +180,7 @@ export function esbuildPlugin(options: ESBuildOptions = {}): Plugin {
// and for build as the final optimization is in `buildEsbuildPlugin`
const transformOptions: TransformOptions = {
target: 'esnext',
charset: 'utf8',
...options,
minify: false,
minifyIdentifiers: false,
Expand Down Expand Up @@ -306,7 +307,9 @@ export function resolveEsbuildTranspileOptions(
// https://github.com/vuejs/core/issues/2860#issuecomment-926882793
const isEsLibBuild = config.build.lib && format === 'es'
const esbuildOptions = config.esbuild || {}

const options: TransformOptions = {
charset: 'utf8',
bluwy marked this conversation as resolved.
Show resolved Hide resolved
...esbuildOptions,
target: target || undefined,
format: rollupToEsbuildFormatMap[format],
Expand Down