Repository navigation
Run @shopify/shopify_function's check before building JavaScript functions - #8829
Closed
saga-dasgupta wants to merge 1 commit into
Closed
saga-dasgupta wants to merge 1 commit into
saga-dasgupta wants to merge 1 commit into
Conversation
Contributor
Author
|
/snapit |
Contributor
|
🫰✨ Thanks @saga-dasgupta! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261008004212Caution After installing, validate the version by running |
Contributor
|
This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. |
saga-dasgupta
force-pushed
the
sd.prepare_variables_check
branch
from
November 9, 2026 15:56
a22f4ca to
2f6337f
Compare
saga-dasgupta
force-pushed
the
sd.prepare_variables_check
branch
from
November 10, 2026 16:47
2f6337f to
82a033c
Compare
saga-dasgupta
added a commit
to Shopify/shopify-function-javascript
that referenced
this pull request
Nov 10, 2026
Add typegen.js, which Shopify CLI runs instead of graphql-code-generator when this package has it (Shopify/cli#8829). It generates the function's types with the codegen plugins this package depends on, gives each prepare result's variables its run query's variables type, and exits non-zero, failing the build, when a prepare target returns variables its run query doesn't accept. The check is moved here from Shopify/cli#8829: it follows what the prepare export returns, ignoring type annotations and casts, and validates it against the run query's variable definitions.
saga-dasgupta
force-pushed
the
sd.prepare_variables_check
branch
from
November 10, 2026 16:56
82a033c to
668c0b1
Compare
saga-dasgupta
added a commit
to Shopify/shopify-function-javascript
that referenced
this pull request
Nov 10, 2026
…query Add typegen.js, which Shopify CLI runs instead of graphql-code-generator when this package has it (Shopify/cli#8829). It generates the function's types with the codegen plugins this package depends on, whatever the app's package manager hoists. It then exits non-zero, failing the build, when a prepare target returns variables its run query doesn't accept. The check is moved here from Shopify/cli#8829: it follows what the prepare export returns, ignoring type annotations and casts, and validates it against the run query's variable definitions.
saga-dasgupta
added a commit
to Shopify/shopify-function-javascript
that referenced
this pull request
Nov 10, 2026
…query Add check.js, which Shopify CLI runs before building a JavaScript function when this package has it (Shopify/cli#8829). It exits non-zero, failing the build, when a prepare target returns variables its run query doesn't accept. The check is moved here from Shopify/cli#8829: it follows what the prepare export returns, ignoring type annotations and casts, and validates it against the run query's variable definitions.
…nction When the function's @shopify/shopify_function has check.js, run it before generating types and bundling, with a JSON file describing the function: its handle, directory, entry and schema, and each target's input query and the export the bundle imports. The package fails the build when a prepare target returns variables its run query doesn't accept. Code generation is unchanged.
saga-dasgupta
force-pushed
the
sd.prepare_variables_check
branch
from
November 10, 2026 20:24
668c0b1 to
690413e
Compare
saga-dasgupta
added a commit
to Shopify/shopify-function-javascript
that referenced
this pull request
Nov 10, 2026
…query Add check.js, which Shopify CLI runs before building a JavaScript function when this package has it (Shopify/cli#8829). It exits non-zero, failing the build, when a prepare target returns variables its run query doesn't accept, and warns about variables it can't check. The check is moved here from Shopify/cli#8829: it follows what the prepare export returns, ignoring type annotations and casts, and validates it against the run query's variable definitions. Values it can't follow, such as parsed JSON, are warnings rather than errors, so valid code still builds.
saga-dasgupta
added a commit
to Shopify/shopify-function-javascript
that referenced
this pull request
Nov 10, 2026
…query Add check.js, which Shopify CLI runs before building a JavaScript function when this package has it (Shopify/cli#8829). It exits non-zero, failing the build, when a prepare target returns variables its run query doesn't accept, and warns about variables it can't check. The check is moved here from Shopify/cli#8829: it follows what the prepare export returns, ignoring type annotations and casts, and validates it against the run query's variable definitions. Values it can't follow, such as parsed JSON, are warnings rather than errors, so valid code still builds.
jacobsteves
reviewed
Nov 12, 2026
saga-dasgupta
added a commit
to Shopify/shopify-function-javascript
that referenced
this pull request
Nov 12, 2026
…query Add check.js, which Shopify CLI runs before building a JavaScript function when this package has it (Shopify/cli#8829). It exits non-zero, failing the build, when a prepare target returns variables its run query doesn't accept, and warns about variables it can't check. The check is moved here from Shopify/cli#8829: it follows what the prepare export returns, ignoring type annotations and casts, and validates it against the run query's variable definitions. Values it can't follow, such as parsed JSON, are warnings rather than errors, so valid code still builds.
saga-dasgupta
added a commit
to Shopify/shopify-function-javascript
that referenced
this pull request
Nov 12, 2026
…query Add check.js, which Shopify CLI runs before building a JavaScript function when this package has it (Shopify/cli#8829). It exits non-zero, failing the build, when a prepare target returns variables its run query doesn't accept, and warns about variables it can't check. The check is moved here from Shopify/cli#8829: it follows what the prepare export returns, ignoring type annotations and casts, and validates it against the run query's variable definitions. Values it can't follow, such as parsed JSON, are warnings rather than errors, so valid code still builds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
A JavaScript function's prepare target returns variables for its run target's input query, and nothing checks them. The earlier version of this PR checked them in the CLI at deploy, so the check, and any change to it, lived in the CLI.
WHAT is this pull request doing?
Before building a JavaScript function, the CLI runs
check.jsfrom the function's@shopify/shopify_function, when the package has it. It passes a JSON file describing the function: its handle, directory, entry and schema, and each target's input query and the export the bundle imports. If the check fails, so does the build, including inapp devandapp deploy:The checker this PR used to add now lives in the package (Shopify/shopify-function-javascript#140), so changes to it ship by updating the package. Warnings the package prints, such as for variables it can't check, don't stop the build. Code generation is unchanged, and packages without
check.jsbuild as before.How to test your changes?
gh pr checkout 140 && npm pack). Install the tarball as@shopify/shopify_functionin a JavaScript function with prepare and run targets.shopify app function buildfrom a/snapitbuild. It fails, naming the file, line and variable.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add