-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
fix type exports for cherry-picked imports #2370
base: next
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
41bd4d9
to
4d99dc8
Compare
"Tests" added in the form of an additional |
4d99dc8
to
0ad804d
Compare
What I'm struggling with right now: If I run
I think it's because TypeScript is finding both the If I run |
fix type exports for cherry-picked imports Previously, the type exports worked for imports that rely on tree-shaking: ```ts import { SlOption } from '@shoelace-style/shoelace/dist/react'; ```` but not for cherry-picked imports: ```ts import SlOption from '@shoelace-style/shoelace/dist/react/option'; ``` This fixes that by declaring the type type exports for all paths. It also adds a new `test/` directory with a few very high-level smoke tests that run against the compiled `dist/` output. See shoelace-style#2111
0ad804d
to
a99c8d7
Compare
|
"./dist/themes/*": { | ||
"types": "./dist/themes/*.d.ts", | ||
"import": "./dist/themes/*.js" | ||
}, |
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.
This is a bug. It makes it impossible to
import '@shoelace-style/shoelace/dist/themes/light.css';
I started integrating with a NextJS application, following this guide. It has examples like import { setBasePath } from "@shoelace-style/shoelace/dist/utilities/base-path.js" and const SlButton = dynamic(
// Notice how we use the full path to the component. If you only do `import("@shoelace-style/shoelace/dist/react")` you will load the entire component library and not get tree shaking.
() => import("@shoelace-style/shoelace/dist/react/button/index.js"),
{
loading: () => <p>Loading...</p>,
ssr: false,
},
); That agrees with the existing import SlButton from '@shoelace-style/shoelace/dist/react/button'; To agree with the NextJS guide, that should be import SlButton from '@shoelace-style/shoelace/dist/react/button/index.js'; |
Previously, the type exports worked for imports that rely on tree-shaking:
but not for cherry-picked imports:
This fixes that by declaring the type type exports for all paths.
See #2111
NOTE the build is set up in such a way that there are some inconsistencies:
themes/
,utilities/
, andtranslations/
, the import is of the form@shoelace-style/shoelace/translations/ar
components/
, the import is of the form@shoelace-style/shoelace/components/alert/alert
react/
, the import is of the form@shoelace-style/shoelace/react/select
and references./dist/react/select/index.js
There aren't any tests for the React wrappers. I think if there were and if they imported from the public paths, not relative ones, they would have caught this.
Some alternate approaches we could use instead:
dist/react/COMPONENT.{js,d.ts}
'@shoelace-style/shoelace/dist/react/COMPONENT/index'