-
Notifications
You must be signed in to change notification settings - Fork 683
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
feat(devex): Refactor Venia to be portable and importable #788
Conversation
This pull request is automatically deployed with Now. |
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. This is a clean set of changes; it's mostly just import swaps, as we discussed. I've left comments in a few places. Other things we've got to do:
- Workshop the name of
@magento-venia/drivers
. It feels inconsistent with our other packages. - Remove
package-lock.json
. Looks like at least one is included in this diff.
backgroundImage: `url(${makeProductMediaPath(image.file)})` | ||
backgroundImage: `url(${new ResourceUrl( | ||
makeProductMediaPath(image.file) | ||
).toString()})` |
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.
We could omit .toString()
in places like this, right? It should be automatically called for expressions in template literal placeholders.
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.
You're right that this would be called implicitly, but that's a little bit magic. It's also there to indicate that ResourceUrl
will probably have other instance methods in the future.
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.
Naming that method toString
is the magic part, though. 😉
package.json
Outdated
"bundlesize": "~0.17.1", | ||
"chalk": "~2.4.2", | ||
"chokidar": "~2.0.4", | ||
"concurrently": "~4.1.0", |
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.
Is this being used anywhere?
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, in Venia's build
script.
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 like it's used in the Peregrine's build script, not Venia's. In either case, the dependency should be listed as a devDependency
of the package itself, not here in the root.
yarn workspace @magento/peregrine add --dev --tilde concurrently
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.
@jimbo Thanks. You shouldn't need the tilde anymore now that we've got a .yarnrc.
Speaking of which: One downside of Yarn is that it doesn't warn you on the command line if two packages have slightly different semver strings for the same dependency. I think we should strive to not let our dependencies between packages drift apart.
package.json
Outdated
@@ -45,9 +46,11 @@ | |||
"devDependencies": { | |||
"@magento/eslint-config": "~1.3.0", | |||
"babel-eslint": "~10.0.1", | |||
"babel-plugin-module-resolver": "^3.1.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.
Consider --tilde
here.
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.
Whoa, how'd that get in there?
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 like Yarn doesn't respect our .npmrc, so I added a .yarnrc to set the default save prefix.
@jimbo Thanks for taking a look. What would you suggest instead of |
080f285
to
d4e3a9a
Compare
@zetlen would the same approach be viable for https://github.com/magento-research/pwa-studio/tree/release/2.0/packages/peregrine |
@jochienabuurs It would! The only reason I did this for Venia first is that Peregrine is about to go through some major API changes after our release. For now, large Peregrine changes are on hold, and Venia is the more useful and feature-complete of the two. However, this PR also makes the existing Peregrine components easier to import. |
Switched to |
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 great! I couldn't find anything that jumped out to me, and it all makes sense. Do we have a follow-up issue for @jcalcaben to add/update docs?
And 👍 for the rename to @magento/venia-drivers
.
1560ede
to
7aa4563
Compare
@zetlen Thanks for responding to the feedback. Take a look through the comments again. One or two minor changes remain, then we're good. |
77aa493
to
b5de6c7
Compare
@zetlen This is approved and ready to go. I'd like to note here that we should probably find a way to do something about the noisy warnings about module resolution. Same for the missing peer dependencies from my Yarn PR. Let's figure out what our options are. |
Description
Change the build configuration and dependency graph of Venia and Peregrine so that community developers can use individual Venia components in external apps.
<Query />
,connect()
,<Link >
,<Route />
, and others through the central drivers file<VeniaAdapter />
@magento/venia-drivers
Motivation and Context
PWA Studio needs to be modular and its components need to be usable and mix-and-matchable at release time. We don't offer "inheritance" in the way of Magento themes, so we have to live up to our promise of modularity and composability. We sacrificed some of that for velocity, and it's time to get that back.
How Has This Been Tested?
Refactored unit tests and restored coverage.
Tested all changed code.
Ran all NPM scripts.
Screenshots (if appropriate):
I built an example app to show how these changes enable import of Venia components á la carte:
https://venia-consuming-app.now.sh/
Its source code is at https://github.com/magento-research/venia-consumer-example and a build artifact is inspectable at https://venia-consuming-app.now.sh/_src . Check it out!
Proposed Labels for Change Type/Package
feature, documentation
peregrine, pwa-buildpack, venia-concept
Checklist: