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

Issue with i18n #89

Closed
keserwan opened this issue Oct 30, 2019 · 8 comments
Closed

Issue with i18n #89

keserwan opened this issue Oct 30, 2019 · 8 comments

Comments

@keserwan
Copy link

keserwan commented Oct 30, 2019

Hi @chrisguttandin, Thank you again for your great contributions.
Sorry to bother you again, I found an issue when you build the project with multi locale (i18n).
You can check this demo project also to reproduce the issue (I pushed the last changes that you fixed in #87):

https://github.com/keserwan/testAngularPrerender

To reporduce it, you run the following commands:

  1. npm i
  2. npm run build:i18n-ssr
  3. npx angular-prerender

npm run build:i18n-ssr: this command will create 2 folders "ar" and "en" in "dist/website/server" and "dist/website/browser".

I am getting this error after calling "npx angular-prerender"
Knowing that main.js is not available in "dist/website/server", it is available in the two folders "en" and "ar".

(node:26332) UnhandledPromiseRejectionWarning: Error: Cannot find module 'C:\Development\test\testPrerender\dist\website\server\main'
Require stack:
- C:\Development\test\testPrerender\node_modules\angular-prerender\build\node\functions\prerender.js
- C:\Development\test\testPrerender\node_modules\angular-prerender\build\node\app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at prerender (C:\Development\test\testPrerender\node_modules\angular-prerender\build\node\functions\prerender.js:74:7)
    at C:\Development\test\testPrerender\node_modules\angular-prerender\build\node\app.js:78:3
(node:26332) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26332) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PS C:\Development\test\testPrerender> 
@chrisguttandin
Copy link
Owner

Hi @keserwan,

you don't bother me at all. I'm happy that you discover all those unsupported edge cases (and that you report them so nicely).

I guess you run ng build with the --configuration flag set to 'production-ar' or 'production-en' respectively, right?

ng build --configuration=production-ar

Currently angular-prerender only support to set the --browser-target but it doesn't allow to specify the configuration. I wonder if it would make sense to support something like this:

npx angular-prerender --configuration=production-ar

What do you think?

@keserwan
Copy link
Author

keserwan commented Oct 31, 2019

Yes I think passing the configuration parameter is what we need.

@chrisguttandin
Copy link
Owner

Hi @keserwan, I just published v4.2.0 which supports full target specifiers similar to the ng run command.

For your app the options do probably look like this:

npx angular-prerender --browser-target website:build:production-ar --server-target website:server:production-ar

I will close the issue now since I expect it work. But as always please feel free to reopen it if you notice any bugs.

@keserwan
Copy link
Author

keserwan commented Nov 4, 2019

Great, I will check and let you know

@keserwan
Copy link
Author

keserwan commented Nov 5, 2019

I updated to version 4.2.0
I got this error after calling:
npx angular-prerender --browser-target website:build:production-ar --server-target website:server:production-ar

(node:15028) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:107:11)
    at join (path.js:372:7)
    at prerender (C:\Development\test\testPrerender\node_modules\angular-prerender\build\node\functions\prerender.js:70:35)
(node:15028) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15028) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I updated the test repo if you want to test with:

https://github.com/keserwan/testAngularPrerender

@chrisguttandin
Copy link
Owner

My bad, thanks for catching this bug. I just released v4.2.1. When I update angular-prerender to that version in your test repo it works.

I accidentally forgot to read the properties from the regular options in case they are not defined in the given configuration. This caused the error since the tsConfig property is defined as a regular option and is not overwritten in the configuration.

@keserwan
Copy link
Author

keserwan commented Nov 7, 2019

with v4.2.1 it worked on the demo but not on my live project.
I am getting another error now:


npx angular-prerender --browser-target website:build:production-ar --server-target website:server:production-ar
(node:25176) UnhandledPromiseRejectionWarning: Error: Cannot find source file for path: C:\Development\ABC-XYZ\ClientApps\node_modules\express\index.js
    at imports (C:\Development\ABC-XYZ\ClientApps\node_modules\guess-parser\dist\guess-parser\index.js:196:15)
    at C:\Development\ABC-XYZ\ClientApps\node_modules\guess-parser\dist\guess-parser\index.js:218:25
    at visitNodes (C:\Development\ABC-XYZ\ClientApps\node_modules\typescript\lib\typescript.js:16631:30)
    at Object.forEachChild (C:\Development\ABC-XYZ\ClientApps\node_modules\typescript\lib\typescript.js:16859:24)
    at SourceFileObject.NodeObject.forEachChild (C:\Development\ABC-XYZ\ClientApps\node_modules\typescript\lib\typescript.js:121410:23)
    at imports (C:\Development\ABC-XYZ\ClientApps\node_modules\guess-parser\dist\guess-parser\index.js:203:8)
    at C:\Development\ABC-XYZ\ClientApps\node_modules\guess-parser\dist\guess-parser\index.js:218:25
    at visitNodes (C:\Development\ABC-XYZ\ClientApps\node_modules\typescript\lib\typescript.js:16631:30)
    at Object.forEachChild (C:\Development\ABC-XYZ\ClientApps\node_modules\typescript\lib\typescript.js:16859:24)
    at SourceFileObject.NodeObject.forEachChild (C:\Development\ABC-XYZ\ClientApps\node_modules\typescript\lib\typescript.js:121410:23)
(node:25176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:25176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@chrisguttandin
Copy link
Owner

The error looks like something in your code is importing "express" and the parser can't find it. Is that possible?

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

No branches or pull requests

2 participants