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

NodeInvocationException: document is not defined on initial project startup. But fine after refreshing page (F5) #50

Open
1 task
bharney opened this issue Oct 27, 2018 · 4 comments

Comments

@bharney
Copy link
Owner

bharney commented Oct 27, 2018

Force VS Build to wait for Webpack Completion before displaying page

  • When developing locally, the VS build is trying to display the site before the webpack build is completed. The webpack build unfortunately takes a few seconds longer than the VS Build and results in NodeInvocationException: document is not defined on page load.
    However if you wait until webpack build completes and refresh the page, everything loads fine. Super irritating.
@bharney bharney changed the title Force VS Build to wait for Webpack Completion before displaying page NodeInvocationException: document is not defined Oct 27, 2018
@bharney bharney changed the title NodeInvocationException: document is not defined NodeInvocationException: document is not defined on initial project startup. But fine after refreshing page (F5) Oct 27, 2018
@bharney
Copy link
Owner Author

bharney commented Nov 27, 2018

Problem is associated with running the server side code before webpack is completed compilation. Additionally entire webpack is run when the webserver starts. Need to prevent this to resolve issue.

@ghost
Copy link

ghost commented Dec 29, 2018

Do you think a multi-stage docker build might help with this? I'm not 100% familiar with your custom webpack build but I know the baked in Angular bundling is an after effect of successfully compiling the server code.

Would it be possible to trigger the webpack build in the Dockerfile manually before starting the server code compilation?
https://docs.docker.com/develop/develop-images/multistage-build/#before-multi-stage-builds

Essentially what I'm saying is can we strip this functionality from the .csproj and put it into the Dockerfile?

<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Message Importance="high" Text="Performing npm install..." />
    <Exec Command="npm install" />
    <Message Importance="high" Text="Creating ClientApp/dist directory..." />
    <MakeDir Directories="ClientApp\dist\" />
    <Message Importance="high" Text="Creating react-loadable.json file..." />
    <WriteLinesToFile File="ClientApp\dist\react-loadable.json" Lines="{}" Overwrite="True" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.prod.js --env.prod" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.server.prod.js --env.prod" />
```XML

@bharney
Copy link
Owner Author

bharney commented Dec 29, 2018

@mtmulch I'd love to remove that setup from the .csproj file and into the docker build. I was trying to figure out at way to do that but no luck. I think this is one of the higher priorities for getting the project running correctly. Its a huge bug that the initial page load is an error message that requires a page refresh. Any help with trouble shooting/ PR is welcome. I would be stoked if this was resolved. 🌮

@ghost
Copy link

ghost commented Oct 1, 2019

@bharney Hello friend, starting a new job this week that I might finally be able to call home and back in my own place in Chicago. I'm gonna take a look at some of this stuff soon on some nights when I'm bored.

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

1 participant