-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix published package exports #9163
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
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/12fd18339821e6b47e38b04c26ca05ec23f7c42a/gradio-4.42.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@12fd18339821e6b47e38b04c26ca05ec23f7c42a#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/12fd18339821e6b47e38b04c26ca05ec23f7c42a/gradio-client-1.5.1.tgz |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested a lot of demos, all look good to me! Thanks @pngwn for taking care of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked around Lite and looks like everything worked well.
Just found |
Do we also want to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!! nice work !!!
This PR fixes the package exports for published NPM packages, and processes them appropriately for consumption.
Main changes:
svelte-package
which strips typescript from svelte files and generates typescript declaration files. Now all consumers can user use these packages in their project even if they aren't using typescript but they will still get fully typed components.gradio
condition which points to the source, so we do not need to build the packages when developing in the repo.gradio
condition to the resolution rules of the vite configs for lite + spautils
package so that it no longer needs a special build process, instead the component loader is passed in as an argument to the class.Conditional exports
There is a concept of 'conditional exports' in node/npm/bundler ecosystem. This essentially allows you to have different entrypoints to you package based upon certain conditions. By default the conditions are just things like
import
andrequire
which are for different module system but you can also use custom ones. We are using two.Our exports look something like this:
types
is for typescript, this is a standard in the ecosystem.svelte
is a special condition that svelte tooling understand, so will work for the svelte ecosystem.gradio
is specific to us. I have setresolve.conditions
in our vite config so it will resolve to this entrypoint in out build system.Order matters here because multiple conditions can match, and the first one takes precedence.
This custom
gradio
condition may seem excessive but it means we can carry on working as normal and custom components are unaffected by these changes, without it we would need to repeatedly rebuild packages which is slow and tedious. I have also added this condition to the js client, so we will no longer need to rebuild the client to see changes reflected in the app.