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

Do we have server built file? #1029

Closed
amerllica opened this issue Mar 30, 2021 · 3 comments · Fixed by #1051
Closed

Do we have server built file? #1029

amerllica opened this issue Mar 30, 2021 · 3 comments · Fixed by #1051

Comments

@amerllica
Copy link
Contributor

Something is not clear for me yet, Do we have server built file or not?

When I run the yarn build command it is obvious we will have all the client assets in the public folder and will serve them to the client, but what about server?

By my understanding by using yarn start command:

"start": "cross-env NODE_ENV=production ts-node --transpile-only --files .",

we will run this file:

// root index.ts file


// Allows you to pre-compile ES6 syntax
require('@babel/register')();

// Used by react-refresh
global.$RefreshReg$ = () => null;
global.$RefreshSig$$ = () => () => null;

// Global variables for server-side
global.__CLIENT__ = false;
global.__SERVER__ = true;
global.__DEV__ = process.env.NODE_ENV === 'development';

// Run assets require hooks
require('./tools/webpack/hooks')();
// Run server
require('./src/server');

it means for the last line require('./src/server'); we are using source code of server/index.ts and in this file in line 11 we have:

import ssr from './ssr';

it means it is source code not built version, even for production. I think there is another solution for production. we should build all the application and store it in just one huge file just for server. and tell the express go and read the server.js file that is built just for production level.

I have very simple configuration, you can check it. it uses exactly this way that I describe above. but my configuration doesn't have features like yours. really I like yours but is it possible to implement server built file?

The first and more important feature for a server.js build file is using powerful node process manager like pm2.

@amerllica
Copy link
Contributor Author

@wellyshen, Duo to this issue, I wanna change SSR render by new configuration, I will use webpack-hot-server-middleware to make the Webpack config as an Array, one for client and one for server, then in the production level, we will have server.js and it is built by my new config. it means for production we will have a fully node commonjs2 application and we won't use ssr.tsx and ts-node for production.

If it is acceptable by you, I will send PR, for now, inside my project I'm using this.

@wellyshen
Copy link
Owner

wellyshen commented Apr 4, 2021

@amerllica We don't have yet. Sorry man, I'm busying for other libraries will back to this starter soon. I plan to build the SSR file when migrating to Webpack v5. Would you mind sharing your solution with me first?

@amerllica
Copy link
Contributor Author

@wellyshen, I know you're busy, me too, for now I'm very busy with a Silicon Valley project. but still I'm so eager to this starter, I mentioned my idea in the first post of this issue, here. Whenever you have time pull it and you can see in the production level we will have a commonjs2 file not reading from source.

@wellyshen wellyshen linked a pull request Apr 24, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants