-
Notifications
You must be signed in to change notification settings - Fork 808
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
Components: use full import paths with JS extensions #41524
base: trunk
Are you sure you want to change the base?
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! |
875446a
to
fb6bbff
Compare
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
dd4066c
to
cfb1624
Compare
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.
Looks good as far as it goes. Some comments inline.
I'm tempted to add a new tools/js-tools/tsconfig.nodenext.json
that sets "module" and "moduleResoltion" to "nodenext" but leaves "noEmit" false, so future PRs will get checked with the right options to require the full paths. OTOH, if someone is going to immediately follow this up with updating it to create a build/
dir, there may not be much need for that. 🤷
import { STORE_ID as CONNECTION_STORE_ID } from '../../../../js-packages/connection/state/store'; | ||
import getSiteAdminUrl from '../../tools/get-site-admin-url'; | ||
import AutomatticBylineLogo from '../automattic-byline-logo'; | ||
import { STORE_ID as CONNECTION_STORE_ID } from '../../../../js-packages/connection/state/store.jsx'; |
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.
At some point this may cause problems. Ideally we really shouldn't be trying to relative-include files from outside of the package, instead this should be something like import { STORE_ID as CONNECTION_STORE_ID } from '@automattic/jetpack-connection';
.
Probably someone did it this way because js-packages/connection also depends on js-packages/components, and the bidirectional dependency makes our tooling unhappy. Maybe it needs to be changed so the necessary info gets passed into this component, or maybe the component should be moved to the connection js-package. Or maybe there's a better idea I don't know about. 😀
Anyway, fixing that can be a left for a different PR.
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.
Yeah, the cyclical dependency is an issue. Updating that relative import that reaches outside of the package to use the .js
extension appears to break the JS Tests on this PR as well.
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.
For now, let's just leave this one as jsx. We'll need to fix the circular dependency anyway before we can make this build properly.
As for the test, it looks like the ts-jest-resolver package we're using doesn't properly handle TypeScript's jsx
option, so it doesn't check for the .jsx
extension. At some point I'll probably need to work around that somehow too.
projects/js-packages/components/components/text/stories/index.stories.tsx
Outdated
Show resolved
Hide resolved
34030cc
to
133e9f3
Compare
Rather than 8e011ec, I think the correct fix would be to add When
|
Proposed changes:
@automattic/jetpack-components
package to specify.js
extensions in import paths, and changes directory imports to specify/index.js
..jsx
extension to the supported aliases in storybook and webpack configs.Other information:
Jetpack product discussion
peb6dq-3ta-p2
Does this pull request change what data or activity we track or use?
No
Testing instructions: