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

When UMD and CJS are output at the same time: ERROR: Expected "(" but found "." #13876

Open
7 tasks done
xanggang opened this issue Jul 17, 2023 · 7 comments
Open
7 tasks done
Labels
bug: upstream Bug in a dependency of Vite feat: library mode p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@xanggang
Copy link

Describe the bug

While I build Output error

dist/lib/build/a.js       0.16 kB │ gzip: 0.16 kB
[vite:esbuild-transpile] Transform failed with 1 error:
vite-starter.umd.cjs:7:16: ERROR: Expected "(" but found "."

Expected "(" but found "."
5  |  })(this, (function (exports) { 'use strict';
6  |  
7  |    function index.utilA(name) {
   |                  ^
8  |      return 1;
9  |    }

✓ built in 296ms
error during build:
Error: Transform failed with 1 error:

Reproduction

https://stackblitz.com/edit/vitejs-vite-jnk7u3?file=src%2F_utils%2Findex.js,src%2Fbuild%2Fa.js,src%2Fbuild%2Fb.js,src%2Fbuild%2Findex.js,vite.config.js&terminal=dev

Steps to reproduce

npm run build

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.20.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.6.3 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^4.4.2 => 4.4.4

Used Package Manager

npm

Logs

✓ 3 modules transformed.
dist/lib/_utils/index.js  0.12 kB │ gzip: 0.13 kB
dist/lib/build/index.js   0.16 kB │ gzip: 0.16 kB
dist/lib/build/a.js       0.16 kB │ gzip: 0.16 kB
[vite:esbuild-transpile] Transform failed with 1 error:
vite-starter.umd.cjs:7:16: ERROR: Expected "(" but found "."

Expected "(" but found "."
5  |  })(this, (function () { 'use strict';
6  |  
7  |    function index.utilA(name) {
   |                  ^
8  |      return 1;
9  |    }

✓ built in 268ms
error during build:
Error: Transform failed with 1 error:
vite-starter.umd.cjs:7:16: ERROR: Expected "(" but found "."
    at failureErrorWithLog (file:///home/projects/vitejs-vite-jnk7u3/node_modules/esbuild/lib/main.js:1636:15)
    at eval (file:///home/projects/vitejs-vite-jnk7u3/node_modules/esbuild/lib/main.js:837:29)
    at responseCallbacks.<computed> (file:///home/projects/vitejs-vite-jnk7u3/node_modules/esbuild/lib/main.js:693:9)
    at handleIncomingPacket (file:///home/projects/vitejs-vite-jnk7u3/node_modules/esbuild/lib/main.js:752:9)
    at Socket.readFromStdout (file:///home/projects/vitejs-vite-jnk7u3/node_modules/esbuild/lib/main.js:669:7)
    at EventEmitter.emit (https://vitejsvitejnk7u3-xdhe.w-credentialless.staticblitz.com/blitz.c53ab388.js:35:143926)
    at addChunk (https://vitejsvitejnk7u3-xdhe.w-credentialless.staticblitz.com/blitz.c53ab388.js:35:541673)
    at readableAddChunk (https://vitejsvitejnk7u3-xdhe.w-credentialless.staticblitz.com/blitz.c53ab388.js:35:541377)
    at Readable.push (https://vitejsvitejnk7u3-xdhe.w-credentialless.staticblitz.com/blitz.c53ab388.js:35:542061)
    at _0x542

Validations

@stackblitz
Copy link

stackblitz bot commented Jul 17, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@wChenonly
Copy link
Contributor

image Are you sure the entrance is correct? entry: './packages/index.ts'

@xanggang
Copy link
Author

图像 你确定入口是正确的吗?条目:'./packages/index.ts'

lib.entry Seems to be covered by rollupOptions.input

@xyx650
Copy link

xyx650 commented Aug 26, 2023

my project has the same problem, help~

@hq229075284
Copy link

hq229075284 commented Sep 4, 2023

@xyx650 a bug for rollup issue

@sapphi-red sapphi-red added bug: upstream Bug in a dependency of Vite p3-minor-bug An edge case that only affects very specific usage (priority) feat: library mode labels Sep 20, 2023
@zu1662
Copy link

zu1662 commented Apr 28, 2024

anyone solved this issue ? I have same problem

@zu1662
Copy link

zu1662 commented Apr 28, 2024

anyone solved this issue ? I have same problem

error during build:
Error: [vite:esbuild-transpile] Transform failed with 1 error:
index.js:8:13: ERROR: Expected ";" but found "."

Expected ";" but found "."
6 |
7 | const numericProp = [Number, String];
8 | const props.makeNumericProp = (defaultVal) => ({
| ^
9 | type: numericProp,
10 | default: defaultVal || 0

at failureErrorWithLog (/Users/huazi/MyCode/kylin-design/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1651:15)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: upstream Bug in a dependency of Vite feat: library mode p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

6 participants