Closed gvc closed 1 week ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
@eduardoformiga
It's very uncommon to remove the core dependency because some functions from @faststore/core are used in our features as API extensions, Section Overrides etc.
but since the CLI depends on Core, it will always be there :)
What's the purpose of this pull request?
This PR aims to make
@faststore/core
a dependency of the@faststore/cli
. It just makes sense. Someone can fork@faststore/core
and never need to use the CLI, but there's hardly any usefulness to the CLI without@faststore/core
.How it works?
The only thing linking Core to the CLI was the
generate-graphql
command on the CLI. It just called back 4 scripts on core'spackage.json
:generate:schema
,generate:codegen
,format:generated
andgenerate:copy-back
. The copy-back command was only needed to improve the DX of customers customizing their GraphQL schema [ref] and it was the only part of the script that needed information available at the CLI level only.Since it was only a DX improvement, all that was needed was, during the
faststore dev
execution I had to generate the new schema, copy the files to the correctnode_modules
dir, and then start the NextJS dev server. In order to do this I split thedev
script intopredev
,dev
, anddev-only
*. From the FastStore CLI I could now callyarn predev
, copy the files to the correct place, and then runyarn dev-only
to start the NextJS dev server.Someone developing on the faststore monorepo (us VTEX developers, or someone contributing to our project) will continue to run core via
yarn dev
. npm, yarn, and pnpm support the lifecycle scripts out of the box. I did the same thing tobuild
for equivalence.One thing that can be up to discussion is the existence of
runCommandSync
util. It was only used ongenerate-graphql
and can be easily removed (in this PR or in a future one).How to test it?
Add this PR
@faststore/cli
from codesandbox as a dependency of the starter store, remove@faststore/core
as an explicit dependency, and@faststore/cli
as a devDependency. Run your store and see that everything still works fine. Or go to the starter preview [PR] here and see the store running in "production".