-
Notifications
You must be signed in to change notification settings - Fork 8
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
Odd behavior importing relative files #38
Comments
that is not supported, but using the https://github.com/widgetti/ipyreact#import-maps you should be able to translate that to a URL that is reachable (via jupyter or an external HTTP server) |
I'm digging into the source code and trying to figure out how to get the behavior that I want. Here is what I'm looking for
Serving these file via URL from jupyter wouldn't work with hot code reloading, without extra work. -- Currently I'm reading through the source code and documentation of IPYReact and Sucrase to figure out the approach that will enable this. I think we want to use sucrase on each individual file. Without the ability to work with multiple files, IPYReact will be limited to fairly simple widgets and concepts. |
I see 2 steps:
The first item maybe should not be explored, maybe at that stage it is time to move to step 2 and use a build tool. I have not yet figured out myself how to write a proper esm module with esbuild, maybe webpack makes that easier? it is important to have react and react-dom as external btw. We might also want to turn off sucrase, since the transpilation is already done by that time. |
I made this toy example to showcase the direct use of React components with anywidget, which ipyreact is build upon. Hope it can be helpful |
Thanks @wangqianwen0418! I’ve tried to document this approach in several places, and thank you for your repo contribution! |
@manzt, absolutely! I recently introduced anywidget to a friend who, like several others, is familiar with react but found it challenging to understand how to use react with anywidget. Hence, I created that toy example to aid his understanding. And thanks for pointing out these resources. I hadn't realized that AnyWidget comes with a Vite plugin - that's super cool! |
This is now documented at https://github.com/widgetti/ipyreact?tab=readme-ov-file#bundled-esm-modules using esbuild. |
I have run into two issues while trying to import relative local tsx files.
FIrst when I moved buckaroo to ipyreact, I got the following error:
from the following widget python code:
in ipyreact-dcf.tsx , here is the relevant line:
import {ColumnsEditor} from './ColumnsEditor';
https://github.com/paddymul/buckaroo/blob/feat/ipyreact/js/components/ipyreact-dcf.tsx
Then I tried to make a reduced test case just in a notebook. In this case the other file (comp1) isn't even imported... but no error is thrown.
The text was updated successfully, but these errors were encountered: