-
-
Notifications
You must be signed in to change notification settings - Fork 865
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
separate folders for client and server? #1374
Comments
If you use typescript I recommend the canary release. For setting custom paths I would have to see your razzle.config.js :) https://github.com/jaredpalmer/razzle/releases/tag/v3.2.0-canary.1 |
I tried having an approach like this comment suggested in another issues like mine. Please see here: #714 (comment). FYI: I added "typescript as a plugin aswell in my config. Other than that I have not tried anything further. |
How stupid of me, I made a somewhat beginner mistake. As the client.tsx was located in src/client i had to resolve the path to src/client/client as it was not named index.tsx.. I solved it! |
@fivethreeo I tried your recommendation of trying the canary release, but all I get is: ReferenceError: resolve is not defined What might I do wrong? |
More like what I did wrong :)
…On Sun, 9 Aug 2020 at 16:46, Pontus Salenbo ***@***.***> wrote:
@fivethreeo <https://github.com/fivethreeo> I tried your recommendation
of trying the canary release, but all I get is:
$ tsc -b && razzle build
/mnt/c/Users/Pontu/Downloads/razzle-3.2.0-canary.1/razzle-3.2.0-canary.1/examples/with-typescript/node_modules/razzle/scripts/build.js:10
throw err;
^
ReferenceError: resolve is not defined
at getModules
(/mnt/c/Users/Pontu/Downloads/razzle-3.2.0-canary.1/razzle-3.2.0-canary.1/examples/with-typescript/node_modules/razzle/config/modules.js:86:24)
at
/mnt/c/Users/Pontu/Downloads/razzle-3.2.0-canary.1/razzle-3.2.0-canary.1/examples/with-typescript/node_modules/razzle/config/createConfigAsync.js:136:27
at new Promise ()
at module.exports
(/mnt/c/Users/Pontu/Downloads/razzle-3.2.0-canary.1/razzle-3.2.0-canary.1/examples/with-typescript/node_modules/razzle/config/createConfigAsync.js:71:10)
at
/mnt/c/Users/Pontu/Downloads/razzle-3.2.0-canary.1/razzle-3.2.0-canary.1/examples/with-typescript/node_modules/razzle/scripts/build.js:97:30
at new Promise ()
at build
(/mnt/c/Users/Pontu/Downloads/razzle-3.2.0-canary.1/razzle-3.2.0-canary.1/examples/with-typescript/node_modules/razzle/scripts/build.js:93:14)
at
/mnt/c/Users/Pontu/Downloads/razzle-3.2.0-canary.1/razzle-3.2.0-canary.1/examples/with-typescript/node_modules/razzle/scripts/build.js:52:16
What might I do wrong?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1374 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAADGWNBTRZWGA6MK3ZBDLR72ZFXANCNFSM4PVQG36A>
.
--
Øyvind Saltvik
|
Try v3.2.0-canary.2 now :) |
npx create-razzle-app@canary --example with-typescript with-typescript --ignore-existing |
I can confirm that the new release works. Is it possible for me to enable eslint for linting when building or is the plugin yet not released? |
Not yet released, currently noone is working on it either. Not sure if eslint handles typescript properly either. So that is a no ;) |
Sorted it out with an extra lint command. TSLint in deprecated so Eslint has plugin for full support of TypeScript. I have one extra question tho as I am slowly learning to razzle. I know that you use hot module reloading but I can't get it to work when using custom paths in razzle config file. I have to manually type rs in the console each time for the server to reload, even though it outputs "server-side HMR enabled" in the console. // eslint-disable-next-line @typescript-eslint/no-var-requires const defaultOptions = { function modifyEntryPoints(baseConfig, env, webpack, userOptions = {}) { const { client, server } = options; module.exports = { |
I think this breaks this part
https://github.com/jaredpalmer/razzle/blob/canary/packages/razzle/config/createConfigAsync.js#L338
Reloading in server might also be broken. But still trying to debug that.
…On Sun, 9 Aug 2020 at 23:51, Pontus Salenbo ***@***.***> wrote:
Sorted it out with an extra lint command. TSLint in deprecated so Eslint
has plugin for full support of TypeScript. I have one extra question tho as
I am slowly learning to razzle. I know that you use hot module reloading
but I can't get it to work when using custom paths in razzle config file. I
have to manually type rs in the console each time for the server to reload,
even though it outputs "server-side HMR enabled" in the console.
I use this approach for modifying entries for server and client, found
from a previous issue.
`_'use strict';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
const defaultOptions = {
server: null,
client: null,
};
function modifyEntryPoints(baseConfig, env, webpack, userOptions = {}) {
const options = { ...defaultOptions, ...userOptions };
const webpackConfig = { ...baseConfig };
const { client, server } = options;
/* This is required to rename the entry points instead of using the
defaults */
if (env.target === 'node' && server) {
webpackConfig.entry = [server];
}
if (env.target !== 'node' && client) {
webpackConfig.entry.client = client;
}
return webpackConfig;
}
module.exports = {
plugins: [
{
func: modifyEntryPoints,
options: {
// main server file is index.ts, thus we dont need it as imports default
to index files
server: path.join(__dirname, './src/server'),
// need the double client, as the main file is not named index.tsx
client: path.join(__dirname, './src/client/client'),
},
},
],
};
`
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1374 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAADGVOCB554FVC2RVXPLLR74K5RANCNFSM4PVQG36A>
.
--
Øyvind Saltvik
|
@fivethreeo I noticed that a new version of the canary branch was available. May I ask how I setup the razzle config in order to just modify my entry paths for client and server? |
https://github.com/jaredpalmer/razzle/blob/canary/packages/razzle/config/paths.js#L67 // razzle.config.js
const path = require('path');
module.exports = {
modifyPaths(
{
webpackObject, // the imported webpack node module
options: {
razzleOptions, // the modified options passed to Razzle in the `options` key in `razzle.config.js` (options: { key: 'value'})
},
paths // the default paths that will be used by Razzle.
}) {
paths.appServerJs = path.join(paths.appPath, 'src/server');
paths.appServerIndexJs = path.join(paths.appPath, 'src');
paths.appClientIndexJs = path.join(paths.appPath, 'src/client');
return paths;
},
} |
Thank you, worked like a charm! Is HMR still broken with custom paths? Or does it require some further configuration? |
Not sure that custom paths is the issue. Will be a new StartServer webpack plugin in razzle 4.0. It is in my github repo aswell so can tweak it myself if I or someone find any issues. |
I am trying out your canary release 4 and encountered som problem with the newSplitChunks(?). C:\Users\Pontu\Desktop\code\TypeScript\razzle-canary\node_modules\razzle\config\createConfigAsync.js:101 Do you want a new issue for this error or? I cant seem to understand what's wrong. I use all experimental features. experimental: { |
I know whats wrong. Will fix it tomorrow :)
…On Thu, 10 Sep 2020 at 23:53, Pontus Salenbo ***@***.***> wrote:
I am trying out your canary release 4 and encountered som problem with the
newSplitChunks(?).
C:\Users\Pontu\Desktop\code\TypeScript\razzle-canary\node_modules\razzle\config\createConfigAsync.js:101
hash.update(module.libIdent({ context: dir }));
^
ReferenceError: dir is not defined.
Do you want a new issue for this error or? I cant seem to understand
what's wrong. I use all experimental features. experimental: {
newBabel: true,
newContentHash: true,
newExternals: true,
newMainFields: true,
newSplitChunks: true,
},
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1374 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAADGRVIPRRZBV6RWUHIELSFFDFJANCNFSM4PVQG36A>
.
--
Øyvind Saltvik
|
@fivethreeo Update: It failed due to the @fortawesome/react-fontawesome npm package, is that of any use? |
Attempted a fix now, try canary.5 :) |
I Can confirm, your fix works. However, it seems to have had an impact on build times, in both dev and production. Is that expected or shall I investigate it further? |
It may be that it bundles wrong somehow, so please do :)
…On Fri, 11 Sep 2020 at 21:10, Pontus Salenbo ***@***.***> wrote:
I Can confirm, your fix works. However, it seems to have had an impact on
build times, in both dev and production. Is that expected or shall I
investigate it further?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1374 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAADGV4M4XZWMKDRK43LR3SFJYZDANCNFSM4PVQG36A>
.
--
Øyvind Saltvik
|
Can you figure out if it is newBabel og newExternals that slows it down? |
It was none of them. The problem was my incorrect usage of plugins i razzle.config.js. I used the old way with the plugins array, instead of .modifyWebpackConfig (as output in console, totally my mistake). This combined with treeshake error in fortawesomes svg icons package caused the slow down. When configured correct, It works like a charm and takes only a few seconds, bundle looks good! (checked with webpack-bundle-analyzer). So it's all good in the new canary.5 :) |
@fivethreeo I tried migrating to v4.0.0-finch.2 and encountered some problems. When running yarn build or yarn start: Is seems like mini-css-extract-plugin is missing from the package.json file. For the test I noticed that the logger is a peerDep, so I tried running npx install-peerdeps razzle@4.0.0-finch.2 but encountered further problems. Is there anything further that I can try in order to provide you/the team all information needed? Maybe move it to another issue as this issue is not really related to my original issue. |
mini-css-extract-plugin is now a peer dep aswell so you have to provide it did a new release finch.3 now to fix the other issue :) |
The original issue is solved. Just open new issues as they crop up 😀 |
By the way do you have your bundle analyzer setup for razzle? I would like to make it a razzle plugin. |
I did not do any specific configuration for this issue. I just pushed an instance of the Webpack-bundle-analyzer into the webpackconfig.plugins. |
❓Question
Hi, I really fancy this project but for large scale applications I prefer to separate the client and the server inside the src folder. I can't quite get the configuration right in the razzle.config.js in order to make it work. I came across this error "Entry module not found: Error: Can't resolve 'C:\Users\Pontu\Desktop\code\TypeScript\razzle-test\src\client'". As you can see, the project is also coded in TypeScript, if that changes anything.
The text was updated successfully, but these errors were encountered: