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

SyntaxError Unexpected token error in react lib build mode #12769

Closed
7 tasks done
chhpt opened this issue Apr 6, 2023 · 4 comments
Closed
7 tasks done

SyntaxError Unexpected token error in react lib build mode #12769

chhpt opened this issue Apr 6, 2023 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@chhpt
Copy link

chhpt commented Apr 6, 2023

Describe the bug

When i try to build a react component lib with the lib mode, i accross a SyntaxError. The dev mode is all right.

Reproduction

CodeSandbox

Steps to reproduce

  1. Wait the codesanbox setup
  2. Create a new terminal
    image
  3. pnpm run build:lib

System Info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 270.16 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.1/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
    Firefox: 109.0.1
    Safari: 16.3
  npmPackages:
    @vitejs/plugin-react: ^3.1.0 => 3.1.0 
    vite: ^4.2.1 => 4.2.1

Used Package Manager

pnpm

Logs

Click to expand!
// paste the log text here
> [email protected] build:lib /project/home/chhpt/workspace
> NODE_ENV=production vite build --config ./vite.config-lib.ts

vite v4.2.1 building for production...
✓ 2 modules transformed.
✓ built in 472ms
[commonjs--resolver] Unexpected token (678:4) in /project/home/chhpt/workspace/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/react-router-dom/dist/index.js
file: /project/home/chhpt/workspace/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/react-router-dom/dist/index.js:678:4
676:     hasSetSearchParamsRef.current = true;
677:     navigate("?" + newSearchParams, navigateOptions);
678:   }, [navigate, searchParams]);
         ^
679:   return [searchParams, setSearchParams];
680: }
error during build:
SyntaxError: Unexpected token (678:4) in /project/home/chhpt/workspace/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/react-router-dom/dist/index.js
    at Object.pp$4.raise (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20978:13)
    at Object.pp$9.unexpected (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:18279:8)
    at Object.pp$5.parseExprAtom (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20362:10)
    at Object.pp$5.parseExprSubscripts (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20154:19)
    at Object.pp$5.parseMaybeUnary (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20120:17)
    at Object.pp$5.parseExprOps (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20047:19)
    at Object.pp$5.parseMaybeConditional (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20030:19)
    at Object.pp$5.parseMaybeAssign (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19997:19)
    at Object.pp$5.parseExpression (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19960:19)
    at Object.pp$8.parseStatement (file:///project/home/chhpt/workspace/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:18469:45)
 ELIFECYCLE  Command failed with exit code 1.

Validations

@chhpt chhpt changed the title SyntaxError Unexpected token error in lib model SyntaxError Unexpected token error in react lib build mode Apr 6, 2023
@sapphi-red
Copy link
Member

The reproduction returns "Whoops, page not found.".

@github-actions
Copy link

github-actions bot commented Apr 6, 2023

Hello @chhpt. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@chhpt
Copy link
Author

chhpt commented Apr 7, 2023

@sapphi-red It seems that codesandbox provide a temporary link. I have updated the link, if it's still not found, you can try import the github repo in the codesandbox

https:/chhpt/react-vite

image

@sapphi-red
Copy link
Member

Duplicate of #10848

@sapphi-red sapphi-red marked this as a duplicate of #10848 Apr 10, 2023
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2023
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed needs reproduction labels Apr 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants