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

Update dependencies to work with Vite and NextJS, combine css files into a single css file #1510

Merged
merged 16 commits into from
Sep 13, 2023

Conversation

vladimir-mck
Copy link
Contributor

@vladimir-mck vladimir-mck commented Aug 30, 2023

Description

Resolves #1293, #1504 and 1512

Development notes

This pull request addresses several JavaScript issues, enhancing the compatibility of Kedro-Viz when integrated with Svelte and Next.js. Although the JS-related errors have been resolved.

  • Replaced lodash. dependencies with lodash to ensure compatibility with both Next.js and Vite.
  • Upgraded Plotly to a newer version to fix errors experienced in both Vite and Next.js environments.
  • Removed css imports from components and replaced with scsc imports
  • Remove script to transform scss into css in dev mode
  • Added script to combine lib css files into a single css file

Vite:
Screenshot 2023-08-29 at 13 17 24
Screenshot 2023-08-29 at 13 17 34

QA notes

Create a new project with Vite:

  • npm create vite@latest my-react-app --template react
  • install kedro-viz alpha version npm i @quantumblack/[email protected]
  • add the component and styles
  • data to it.

Create a new project with NextJS:

  • npx create-next-app@latest
  • install kedro-viz alpha version npm i @quantumblack/[email protected]
  • Import kedro following update readme

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

@vladimir-mck vladimir-mck self-assigned this Aug 30, 2023
@vladimir-mck vladimir-mck changed the title Update dependencies, update apollo config, update worker to use a moc… Fix server side rendering bugs, update dependencies to work with Vite and NextJS Aug 30, 2023
Copy link
Contributor

@ravi-kumar-pilla ravi-kumar-pilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Vlad !!

Some questions -

  1. I want to understand why we need apollo config refactoring ?
  2. I have tested the PR using the QA notes, the alpha release works well except for the CSS errors (as you mentioned). Just to confirm, I am attaching the errors during the run

Svelte error -

Screenshot 2023-08-31 at 5 54 08 PM

Next.js error -

Screenshot 2023-08-31 at 6 02 31 PM

@vladimir-mck
Copy link
Contributor Author

vladimir-mck commented Sep 1, 2023

Hey Ravi

  1. I want to understand why we need apollo config refactoring ?

So here we needed a bit of a refactor because it tries to access the window.location object to get the host, path name and protocol. The window object doesn't exist when it's rendered on the server and it's throwing an error, additionally the web socket link will also throw an error.

  1. I have tested the PR using the QA notes, the alpha release works well except for the CSS errors (as you mentioned). Just to confirm, I am attaching the errors during the run

Yep, that's okay. The css error is not present when started with Vite. Next has it's own rules how to handle css and that's why it's throwing an error. I have to agree with them on this, we shouldn't release with 66 css files, one is enough.

@vladimir-mck vladimir-mck changed the title Fix server side rendering bugs, update dependencies to work with Vite and NextJS Update dependencies to work with Vite and NextJS, combine css files into a single css file Sep 6, 2023
vladimir-mck and others added 8 commits September 6, 2023 13:02
* Fix: Adding favicon to Kedro Demo

* Fix: Change in approach for serving favicon

* Lint error fix

* Lint error fix

* Favicon endpoint test added

* Favicon endpoint test added

* Lint error fixed

* Fix: Adding favicon to Kedro Demo

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Fix: Change in approach for serving favicon

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Lint error fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Lint error fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Favicon endpoint test added

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Favicon endpoint test added

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Lint error fixed

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Fixed favicon endpoint test

* Release doc updated

* Update RELEASE.md

Co-authored-by: rashidakanchwala <[email protected]>

* Removed pytest.fixture as per review comment

---------

Signed-off-by: Jitendra Gundaniya <[email protected]>
Co-authored-by: rashidakanchwala <[email protected]>
Signed-off-by: Vladimir <[email protected]>
* v6.5.0

* release

* update-reminder-content

* update reminder

Signed-off-by: Vladimir <[email protected]>
Signed-off-by: Vladimir <[email protected]>
… update babel to remove scss imports from the lib components. Revert apollo config and worker

Signed-off-by: Vladimir <[email protected]>
Signed-off-by: Vladimir <[email protected]>
Copy link
Member

@tynandebold tynandebold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is looking fantastic. I'm excited for this change to go in.

One thing when I'm trying to test is I can't install the alpha version of the package. I get this error:

image

Do you see the same?

Copy link
Member

@tynandebold tynandebold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this out using create react app and everything loads and works fine. I see that some of the styles are off though. Have a look:

Screenshot 2023-09-08 at 11 18 06

This is the alpha version I'm using: "@quantumblack/kedro-viz": "^6.5.1-alpha.2".

Copy link
Member

@tynandebold tynandebold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice! Everything is looking great and working well.

I've left a couple small comments, nothing blocking.

RELEASE.md Outdated
@@ -17,7 +23,7 @@ Please follow the established format:
- Fix to search for a '<lambda' Python function in the sidebar. (#1497)
- Add favicon to Kedro-Viz. (#1509)
- Remove python upper-bound requirements and add KedroVizPythonVersion warning. (#1506)

- Resolved various bugs affecting server-side rendering, updated dependencies to ensure compatibility with Vite and Next.js environments (#1508)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here? That PR was never merged, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

RELEASE.md Outdated Show resolved Hide resolved
@tynandebold tynandebold removed the request for review from yetudada September 12, 2023 17:42

const NoSSRKedro = dynamic(() => import('@quantumblack/kedro-viz'), {
ssr: false,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome !!

Copy link
Contributor

@ravi-kumar-pilla ravi-kumar-pilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work Vlad 👍 . Need some changes with the release doc but nothing blocking.

@vladimir-mck vladimir-mck merged commit 2d0c577 into main Sep 13, 2023
1 check passed
@vladimir-mck vladimir-mck deleted the bugfix/1293-1504 branch September 13, 2023 09:35
@tynandebold tynandebold mentioned this pull request Oct 10, 2023
5 tasks
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 this pull request may close these issues.

Importing Kedro-Viz React-Component in Svelte
5 participants