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

react-ts template doesn't build in production #2562

Closed
3 tasks done
Litarvan opened this issue Mar 17, 2021 · 0 comments · Fixed by #2566
Closed
3 tasks done

react-ts template doesn't build in production #2562

Litarvan opened this issue Mar 17, 2021 · 0 comments · Fixed by #2566

Comments

@Litarvan
Copy link

Litarvan commented Mar 17, 2021

⚠️ IMPORTANT ⚠️ Please do not ignore this template. If you do, your issue will be closed immediately.

Describe the bug

Running npm run build on the react-ts template drops a build error due to the const [count, setCount] = useState(0); line in the src/App.tsx file, being reported as 'not supported'.

error during build:
Error: Transform failed with 1 error:
assets/index.d6b4819c.js:48:8: error: Transforming destructuring to the configured target environment ("chrome61", "edge16", "es2019", "firefox60", "safari11") is not supported yet
    at failureErrorWithLog (PROJET_PATH/node_modules/esbuild/lib/main.js:1195:15)
    at PROJET_PATH/node_modules/esbuild/lib/main.js:1056:33
    at PROJET_PATH/node_modules/esbuild/lib/main.js:566:9
    at handleIncomingPacket (PROJET_PATH/node_modules/esbuild/lib/main.js:655:9)
    at Socket.readFromStdout (PROJET_PATH/node_modules/esbuild/lib/main.js:533:7)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:284:9)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Removing the destructuration at the line 6 of the src/App.tsx file fixes the issue and it builds properly, but I don't think this is intented.

Reproduction

npm init @vitejs/app test # Select the `react-ts` template
cd test
npm i
npm run build

System Info

Tested on two different setups, both dropping the same error :

First setup:

  • vite version: vite/2.1.1 darwin-x64 node-v14.15.1
  • Operating System: macOS 11.1 (Hackintosh on Intel CPU)
  • Node version: 14.15.1
  • Package manager (npm/yarn/pnpm) and version: NPM 6.14.8

Second setup:

  • vite version: vite/2.1.1 linux-x64 node-v15.8.0
  • Operating System: NixOS 20.09
  • Node version: 15.8.0
  • Package manager (npm/yarn/pnpm) and version: NPM 7.5.1

Logs (Optional if provided reproduction)

$ node_modules/.bin/vite build --debug
  vite:config bundled config file loaded in 595ms +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'alias',
  vite:config     'react-refresh',
  vite:config     'vite:dynamic-import-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'vite:import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter'
  vite:config   ],
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge16', 'firefox60', 'chrome61', 'safari11' ],
  vite:config     polyfillDynamicImport: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     minify: 'terser',
  vite:config     terserOptions: {},
  vite:config     cleanCssOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500
  vite:config   },
  vite:config   configFile: 'PROJECT_PATH/vite.config.ts',
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     build: {}
  vite:config   },
  vite:config   root: 'PROJECT_PATH',
  vite:config   base: '/',
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: 'PROJECT_PATH/public',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isProduction: true,
  vite:config   optimizeCacheDir: 'PROJECT_PATH/node_modules/.vite',
  vite:config   server: {},
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   },
  vite:config   createResolver: [Function: createResolver]
  vite:config } +7ms
vite v2.1.1 building for production...
✓ 21 modules transformed.
  vite:esbuild esbuild error with options used:  {
  loader: 'js',
  sourcemap: true,
  sourcefile: 'assets/index.d6b4819c.js',
  target: [ 'es2019', 'edge16', 'firefox60', 'chrome61', 'safari11' ],
  minify: false
} +0ms
error during build:
Error: Transform failed with 1 error:
assets/index.d6b4819c.js:48:8: error: Transforming destructuring to the configured target environment ("chrome61", "edge16", "es2019", "firefox60", "safari11") is not supported yet
    at failureErrorWithLog (PROJECT_PATH/node_modules/esbuild/lib/main.js:1195:15)
    at PROJECT_PATH/node_modules/esbuild/lib/main.js:1056:33
    at PROJECT_PATH/node_modules/esbuild/lib/main.js:566:9
    at handleIncomingPacket (PROJECT_PATH/node_modules/esbuild/lib/main.js:655:9)
    at Socket.readFromStdout (PROJECT_PATH/node_modules/esbuild/lib/main.js:533:7)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:284:9)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant