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

Bumped react-script, seems to fix install and run issues #32

Merged
merged 14 commits into from
May 10, 2023

Conversation

blackary
Copy link
Collaborator

Fixes #29 #30 #21, I believe

Before:

npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-scripts@3.4.1
npm ERR! Found: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR!   typescript@"^4.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@3.4.1
npm ERR! node_modules/react-scripts
npm ERR!   react-scripts@"3.4.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@3.9.10
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"^3.2.1" from react-scripts@3.4.1
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"3.4.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/zblackwood/.npm/_logs/2023-04-11T14_40_28_942Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zblackwood/.npm/_logs/2023-04-11T14_40_28_942Z-debug-0.log

After this change, npm install and npm run start run without errors

npm --version 
9.3.1

node --version
v19.5.0

@blackary blackary changed the title Bumped react-script, seems to fix arrow issues Bumped react-script, seems to fix install and run issues Apr 11, 2023
@sfc-gh-kbregula sfc-gh-kbregula self-requested a review April 26, 2023 08:47
@sfc-gh-kbregula
Copy link
Contributor

I checked and it seems to me that this is not a complete solution, but a step in the right direction.

When I used node v18.15.0 (npm v9.5.0) I was able to install all packages from template directory.

But npm run start command fails with the error below

Starting the development server...

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/NormalModule.js:417:16)
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/NormalModule.js:452:10
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/webpack/lib/NormalModule.js:323:13
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /Users/kbregula/Snowflake/streamlit/component-template/template/my_component/frontend/node_modules/babel-loader/lib/index.js:59:103 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.15.0

I also see that Typescript is not happy and modifies its configurations.

The following changes are being made to your tsconfig.json file:
  - compilerOptions.noFallthroughCasesInSwitch to be suggested value: true (this can be changed)
  - compilerOptions.jsx must be react-jsx (to support the new JSX transform in React 17)
$ diff --git a/template/my_component/frontend/tsconfig.json b/template/my_component/frontend/tsconfig.json
index af10394..e18c413 100644
--- a/template/my_component/frontend/tsconfig.json
+++ b/template/my_component/frontend/tsconfig.json
@@ -1,7 +1,11 @@
 {
   "compilerOptions": {
     "target": "es5",
-    "lib": ["dom", "dom.iterable", "esnext"],
+    "lib": [
+      "dom",
+      "dom.iterable",
+      "esnext"
+    ],
     "allowJs": true,
     "skipLibCheck": true,
     "esModuleInterop": true,
@@ -13,7 +17,10 @@
     "resolveJsonModule": true,
     "isolatedModules": true,
     "noEmit": true,
-    "jsx": "react"
+    "jsx": "react-jsx",
+    "noFallthroughCasesInSwitch": true
   },
-  "include": ["src"]
+  "include": [
+    "src"
+  ]
 }

This may not be related to the react-script update, but I'm not sure.

I also tried running our second template (template-reactless) and it still doesn't work. This looks like the same problem but in a different directory.

$ (nvm use v18.15.0; cd template-reactless/my_component/frontend; npm install)

Now using node v18.15.0 (npm v9.5.0)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-scripts@3.4.1
npm ERR! Found: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR!   typescript@"^4.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@3.4.1
npm ERR! node_modules/react-scripts
npm ERR!   react-scripts@"3.4.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@3.9.10
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"^3.2.1" from react-scripts@3.4.1
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"3.4.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/kbregula/.npm/_logs/2023-04-26T10_56_10_835Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kbregula/.npm/_logs/2023-04-26T10_56_10_835Z-debug-0.log

I am also not sure if this PR solves all the tickets you mentioned in the description of the PR.
For example, #30 is a typescript configuration problem. I think, we should update apache-arrow library in streamlit-component-lib package, as the workaround we added(a declaration directory) to use apache-arrow 0.17.0 is not compatible with the new version of Typescript.

I too would like to let you know that the Warsaw team has it on the radar. I described these problems and proposed solutions in the document: 🐈‍⬛ Component development issues We wanted to tackle this at the beginning of the next quarter, and for now, focus on the goals of this quarter.

CC: @sfc-gh-mnowotka

@sfc-gh-kbregula
Copy link
Contributor

I'm also wondering if we shouldn't also update the examples to use the newer version of react-scripts package.
https://github.com/streamlit/component-template/blob/master/examples/CustomDataframe/frontend/package.json

Copy link
Contributor

@tconkling tconkling left a comment

Choose a reason for hiding this comment

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

This works for me as well. Huzzah - thanks @blackary!

@tconkling
Copy link
Contributor

tconkling commented Apr 26, 2023

@sfc-gh-kbregula - thanks for looking about this more thoroughly. I'll let you guys handle the merging; feel free to close this PR if you'd rather wait to address all the issues!

@sfc-gh-kbregula
Copy link
Contributor

sfc-gh-kbregula commented May 9, 2023

@tconkling I updated the PR. Now we have CI setup and in addition to templates, examples also work. Can I ask for review?

Copy link
Contributor

@tconkling tconkling left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for taking this on!

from pathlib import Path
import json
import sys

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a short docstring explaining the purpose of this script? Is it something we expect users to use, or is it just for Streamlit devs? (Should we include info about it in the repo's README?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. Added.

Copy link
Contributor

@tconkling tconkling left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for taking this on!

@sfc-gh-kbregula sfc-gh-kbregula merged commit 2a81337 into master May 10, 2023
6 checks passed

To list the available commands, run ./dev.py --help.
"""
import argparse

Choose a reason for hiding this comment

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

FYI, if you're looking for other make alternatives, I really like https://taskfile.dev/

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.

Failed to compile
4 participants