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

Cannot build typescript ssr file #4887

Closed
7 tasks done
JakeGinnivan opened this issue Sep 9, 2021 · 3 comments · Fixed by #5515
Closed
7 tasks done

Cannot build typescript ssr file #4887

JakeGinnivan opened this issue Sep 9, 2021 · 3 comments · Fixed by #5515
Milestone

Comments

@JakeGinnivan
Copy link

Describe the bug

When trying to get SSR working, the sample project will not build in production mode. I think the code which sets process.env.NODE_ENV is being replaced, so that variable can't be assigned?

$ /Users/jakeginnivan/_code/vite-ts-ssr/vite-project/node_modules/.bin/vite build --outDir dist/server --ssr src/entry-server.ts
vite v2.5.6 building SSR bundle for production...
✓ 62 modules transformed.
[commonjs] Assigning to rvalue (33444:4) in /Users/jakeginnivan/_code/vite-ts-ssr/vite-project/node_modules/vite/dist/node/chunks/dep-9f74b403.js
file: /Users/jakeginnivan/_code/vite-ts-ssr/vite-project/node_modules/vite/dist/node/chunks/dep-9f74b403.js:33444:4
33442: 
33443:   if (!ctx.env) {
33444:     process.env.NODE_ENV = 'development';
           ^
33445:   }

My naive guess is that what is actually happening is 'production' = 'development'?

It is possible this is another variation of #3229, but thought I would open a fresh issue because the symptoms are a bit different.

Reproduction

https://github.com/JakeGinnivan/vite-ssr-build-issue

Then run yarn && yarn vite build --outDir dist/server --ssr src/entry-server.ts.

System Info

npx: installed 1 in 1.542s

  System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 258.38 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.3 - /usr/local/opt/node@14/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.13 - /usr/local/opt/node@14/bin/npm
  Browsers:
    Chrome: 93.0.4577.63
    Firefox: 91.0.2
    Safari: 14.1.2
  npmPackages:
    vite: ^2.5.4 => 2.5.6

Used Package Manager

yarn

Logs

--debug flag offered no additional info over the above error

Validations

@imccode
Copy link

imccode commented Nov 12, 2021

好奇怪,我对客户端js进行ssr打包没有问题,对nodejs的代码进行库打包或者ssr打包也遇到了相同的问题

@zhangyuang
Copy link
Contributor

The same error

@haoqunjiang
Copy link
Member

This will be fixed by #5515 and we plan to ship that in 2.8

@Shinigami92 Shinigami92 added this to the 2.8 milestone Dec 7, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants