-
Notifications
You must be signed in to change notification settings - Fork 553
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
Can now export from @primer/react/drafts #1771
Conversation
|
size-limit report 📦
|
UpdateThis does seem to work! Try it for yourself by using this canary version PS - Does this need a changeset? |
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.
Yes!! Thank you for this <3
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.
Not 100% sure if it's working or if I'm doing this wrong but...
In my package.json
I've added:
"@primer/react": "primer/react#pk/exports",
.
But then I get an import error:
Module not found: Can't resolve '@primer/react' in '/workspaces/search/src'
I also can't see a the lib-esm
folder in ./node_modules/@primer/react
that is defined in exports
.
UPDATE: @siddharthkp explained me that we don't support pointing to branches right now and I need to use the generated id however the same error still happens.
@pksjce Should we add IconButton to drafts as well? |
Update: Aww, tried to use this with webpack and it doesn't pick it up automatically :( (I think it works on codesandbox because it uses sandpack instead of webpack) |
@siddharthkp - Also yeah, this exports syntax seems to not be fully supported by webpack 5 and not at all supported in webpack 4. I wonder how the other bundlers will react to this either. Will investigate more. Until then |
Sounds good. Before we close this issue can we make sure we update all our docs to have those new instructions on how to import those components? |
I can create a PR :) |
Try conditional subpaths Change tsconfig files Add package.json hack to drafts
@siddharthkp , after much trial and error, I seem to have fixed this PR to make it backward compatible with the
seems to have done the trick. |
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.
Let's gooooo!
Dismiss sounds so haughty lol. I think I've made the requested changes! Want to merge them!
Invalid typescript version makes `npm ci` fail in the latest npm npm/cli#4363 Merge conflict was introduced in primer#1771
Invalid typescript version makes `npm ci` fail in the latest npm npm/cli#4363 Merge conflict was introduced in #1771
Describe your changes here.
Right now, we need to import draft components from
@primer/react/lib-esm/drafts
. This is less than ideal.In our docs, we have aliased
@primer/react
to the src folder relatively. So it works for our documentation site.But it clearly does not work elsewhere as demonstrated in #1768
Our module definition right now defines
lib-esm/index.js
as the main module import inpackage.json
. We need to aliasdrafts
to work as expected.One option is to use workspaces. I think this is unwieldy for our current usecase.
This blogpost suggested
module-alias
, but there's a new update to go for subpath-imports.I'm trying it out with this PR. I need a build package to verify if it's working
Screenshots
Please provide before/after screenshots for any visual changes
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.