Skip to content

Commit

Permalink
feat!: set esbuild default charset to utf8 (#10753)
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Nov 9, 2022
1 parent d5fe92c commit 4caf4b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
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',
...esbuildOptions,
target: target || undefined,
format: rollupToEsbuildFormatMap[format],
Expand Down

0 comments on commit 4caf4b6

Please sign in to comment.