Describe the bugI am trying to generate a build for a repo and it has DraftJS library , but it is throwing unexpected token error,I am new to vite and I am not able to fix , Here is the link to regenerate the same url, you need to run Error Log Reproductionhttps://stackblitz.com/edit/vitejs-vite-z3ntjd?file=package.json&terminal=dev System InfoSystem:
OS: macOS 12.1
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 18.64 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.9.0 - ~/.nvm/versions/node/v16.9.0/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 7.21.1 - ~/.nvm/versions/node/v16.9.0/bin/npm
Browsers:
Brave Browser: 97.1.34.81
Chrome: 98.0.4758.102
Firefox: 97.0
Safari: 15.2
npmPackages:
@vitejs/plugin-react: ^1.0.7 => 1.2.0
vite: ^2.8.0 => 2.8.3Used Package Manageryarn Logsvite:config bundled config file loaded in 474.40ms +0ms
vite:config using resolved config: {
vite:config plugins: [
vite:config 'alias',
vite:config 'vite:react-babel',
vite:config 'vite:react-refresh',
vite:config 'vite:react-jsx',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm',
vite:config 'vite:worker',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:asset',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:watch-package-data',
vite:config 'vite:build-html',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'rollup-plugin-dynamic-import-variables',
vite:config 'vite:asset-import-meta-url',
vite:config 'vite:build-import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:terser',
vite:config 'vite:reporter',
vite:config 'vite:load-fallback'
vite:config ],
vite:config define: { global: {}, 'process.env': {} },
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config sourcemap: false,
vite:config rollupOptions: {},
vite:config minify: 'esbuild',
vite:config terserOptions: {},
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 reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config resolve: { dedupe: [ 'react', 'react-dom' ], alias: [ [Object], [Object] ] },
vite:config optimizeDeps: {
vite:config include: [ 'react/jsx-dev-runtime' ],
vite:config esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
vite:config },
vite:config configFile: '/home/projects/vitejs-vite-z3ntjd/vite.config.js',
vite:config configFileDependencies: [ 'vite.config.js' ],
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: '/home/projects/vitejs-vite-z3ntjd',
vite:config base: '/',
vite:config publicDir: '/home/projects/vitejs-vite-z3ntjd/public',
vite:config cacheDir: '/home/projects/vitejs-vite-z3ntjd/node_modules/.vite',
vite:config command: 'build',
vite:config mode: 'production',
vite:config isProduction: true,
vite:config server: {
vite:config preTransformRequests: true,
vite:config fs: { strict: true, allow: [Array], deny: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined,
vite:config headers: undefined
vite:config },
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 warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen],
vite:config hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) { set: [Function (anonymous)] },
vite:config createResolver: [Function: createResolver],
vite:config worker: {
vite:config format: 'iife',
vite:config plugins: [
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object]
vite:config ],
vite:config rollupOptions: {}
vite:config }
vite:config } +10ms
vite v2.8.4 building for production...
✓ 67 modules transformed.
[commonjs] Unexpected token (695:10) in /home/projects/vitejs-vite-z3ntjd/node_modules/draft-js/lib/DraftEditor.react.js
file: /home/projects/vitejs-vite-z3ntjd/node_modules/draft-js/lib/DraftEditor.react.js:695:10
error during build:
SyntaxError: Unexpected token (695:10) in /home/projects/vitejs-vite-z3ntjd/node_modules/draft-js/lib/DraftEditor.react.js
at Parser.pp$4.raise (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:19609:13)
at Parser.pp$9.unexpected (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:16905:8)
at Parser.pp$5.parseExprAtom (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:18984:10)
at Parser.pp$5.parseExprSubscripts (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:18776:19)
at Parser.pp$5.parseMaybeUnary (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:18742:17)
at Parser.pp$5.parseExprOps (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:18669:19)
at Parser.pp$5.parseMaybeConditional (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:18652:19)
at Parser.pp$5.parseMaybeAssign (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:18619:19)
at Parser.pp$5.parseExpression (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:18582:19)
at Parser.pp$8.parseStatement (/home/projects/vitejs-vite-z3ntjd/node_modules/rollup/dist/shared/rollup.js:17095:45)Validations
|
Answered by
cata-on
May 4, 2022
Replies: 3 comments 9 replies
|
👋 I got this workaround that simultaneously supports running the app in In my <script>const global = {}</script>Hope this helps. |
4 replies
Answer selected by
bluwy
|
define: { We can update vite.config.ts to fix build error like this. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

👋
I got this workaround that simultaneously supports running the app in
devand thebuild.In my
index.html, I've added:Hope this helps.