Skip to content

Add support for Hydrogen#143

Merged
marcospassos merged 13 commits into
masterfrom
hydrogen
Jun 18, 2026
Merged

Add support for Hydrogen#143
marcospassos merged 13 commits into
masterfrom
hydrogen

Conversation

@marcospassos

Copy link
Copy Markdown
Member

Summary

Add support for Hydrogen.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@marcospassos marcospassos requested a review from Copilot June 18, 2026 19:24
@marcospassos marcospassos added the feature New feature label Jun 18, 2026
@github-actions

Copy link
Copy Markdown

👋 @marcospassos
Thanks for your contribution!
The approval and merge process is almost fully automated 🧙
Here's how it works:

  1. You open a new pull request
  2. Automated tests check the code
  3. Maintainers review the code
  4. Once approved, the PR is ready to merge.

👉 Omit the extended description
Please remove the commit body before merging the pull request.
Instead, include the pull request number in the title to provide the full context
about the change.

☝️ Lastly, the title for the commit will come from the pull request title. So please provide a descriptive title that summarizes the changes in 50 characters or less using the imperative mood.
Happy coding! 🎉

@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/croct@143

commit: 9be71e6

Comment on lines +20 to +22
* When true, throw if there is no session `Set-Cookie` to anchor to (instead of a silent
* no-op), so the SDK can report the failure.
*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Comment on lines +26 to +32
* Ensures the `export const middleware` array contains a `<middleware>()` call and adds the import:
* - creates `export const middleware = [<middleware>()]` when absent;
* - appends to an existing array;
* - normalizes a non-array value (e.g. `buildMiddleware()`) to
* `[...(Array.isArray(existing) ? existing : [existing]), <middleware>()]`, preserving it.
*
* Returns unmodified when the middleware is already registered.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Comment on lines +64 to +67
/**
* When true, throw if no component could be wrapped (instead of a silent no-op), so the SDK
* can report the failure. Already-wrapped inputs stay a clean no-op.
*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all comment slike this

Comment on lines +18 to +25
/**
* Resolves an import specifier written in `sourcePath` to the project-relative file path it
* points to (specifier → file), the inverse of {@link getImportPath}.
*
* Honors the project's tsconfig `paths`/`baseUrl` aliases and relative specifiers, then probes
* extensions (`.ts`, `.tsx`, `.js`, `.jsx`, and `index.*`) the way the TypeScript/Node resolver
* does. Returns null for bare packages or when no matching file exists.
*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not ts specific, remove it. Make it a one liner

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class Hydrogen platform support to the CLI by introducing a new Hydrogen SDK, associated codemods (Vite plugin registration, provider wiring, middleware/context/cookies/CSP), and broadening “required codemod” failure handling across several existing integrations.

Changes:

  • Introduces Platform.HYDROGEN, a PlugHydrogenSdk, and Hydrogen dev-server command parsing/wiring in the CLI.
  • Adds multiple Hydrogen-specific codemods + new JS utilities (spreadAsArray, getImportSource) with extensive fixture/snapshot coverage.
  • Updates several existing codemods/SDKs to support required: true behavior (throwing on “not found” anchors) and improves user-facing failure guidance.

Reviewed changes

Copilot reviewed 142 out of 142 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/application/project/code/transformation/php/symfonyBundleCodemod.test.ts Adds required-mode throw test coverage.
test/application/project/code/transformation/php/drupalLocalSettingsCodemod.test.ts Adds required-mode throw test coverage.
test/application/project/code/transformation/javascript/vueStoryblokCodemod.test.ts Adds required-mode throw tests for missing anchors/imports.
test/application/project/code/transformation/javascript/vuePluginCodemod.test.ts Adds required-mode throw test coverage.
test/application/project/code/transformation/javascript/viteConfigPluginCodemod.test.ts New tests for Vite plugin registration codemod (Hydrogen).
test/application/project/code/transformation/javascript/utils/getImportSource.test.ts New unit tests for getImportSource helper.
test/application/project/code/transformation/javascript/storyblokInitCodemod.test.ts Adds required-mode throw test coverage.
test/application/project/code/transformation/javascript/nuxtConfigModuleCodemod.test.ts Adds required-mode throw test coverage.
test/application/project/code/transformation/javascript/jsxWrapperCodemod.test.ts Adds new fixture scenarios + required-mode throw/idempotence tests.
test/application/project/code/transformation/javascript/hydrogenMiddlewareCodemod.test.ts New codemod tests for Hydrogen middleware registration.
test/application/project/code/transformation/javascript/hydrogenCspCodemod.test.ts New codemod tests for Hydrogen CSP updates.
test/application/project/code/transformation/javascript/hydrogenCookiesCodemod.test.ts New codemod tests for writing cookies after session commit.
test/application/project/code/transformation/javascript/hydrogenContextCodemod.test.ts New codemod tests for exposing Croct context in load context.
test/application/project/code/transformation/javascript/snapshots/viteConfigPluginCodemod.test.ts.snap Snapshots for Vite config plugin transformations.
test/application/project/code/transformation/javascript/snapshots/nuxtConfigModuleCodemod.test.ts.snap Snapshot update for non-array modules normalization behavior.
test/application/project/code/transformation/javascript/snapshots/nextJsProxyCodemod.test.ts.snap Adds snapshot for a new Next.js proxy reexport+config fixture.
test/application/project/code/transformation/javascript/snapshots/jsxWrapperCodemod.test.ts.snap Snapshots for expanded JSX wrapper scenarios (incl. Hydrogen patterns).
test/application/project/code/transformation/javascript/snapshots/hydrogenMiddlewareCodemod.test.ts.snap Snapshots for Hydrogen middleware codemod transformations.
test/application/project/code/transformation/javascript/snapshots/hydrogenCspCodemod.test.ts.snap Snapshots for Hydrogen CSP codemod transformations.
test/application/project/code/transformation/javascript/snapshots/hydrogenCookiesCodemod.test.ts.snap Snapshots for Hydrogen cookies codemod transformations.
test/application/project/code/transformation/javascript/snapshots/hydrogenContextCodemod.test.ts.snap Snapshots for Hydrogen context codemod transformations.
test/application/project/code/transformation/fixtures/vite-config-plugin/uninitializedBinding.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/stringLiteralPluginsKey.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/standard.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/spreadConfigProperties.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/sparsePluginsArray.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/satisfiesConfig.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/remixPlugins.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/positionStart.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/noPluginsKey.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/nonDefineConfigCall.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/nonArrayPlugins.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/memberCalleeExport.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/indirectNonDefineCall.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/indirectConfigWithExtraDeclarator.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/indirectConfigVariable.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/importPresentNoCall.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/functionDefaultExport.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/functionConfig.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/emptyPlugins.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/emptyDefineCall.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/bareObjectIndirectVariable.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/bareObjectExport.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/asConstConfig.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/alreadyRegistered.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/vite-config-plugin/aliasedDefineConfig.ts New Vite config fixture.
test/application/project/code/transformation/fixtures/nextjs-proxy/existingProxyReexportWithConfig.ts New Next.js proxy fixture for reexport-with-config.
test/application/project/code/transformation/fixtures/jsx-wrapper/targetSingleChild.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/targetComponentMemberExpression.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/defaultExportUninitializedReference.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerSelfClosing.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerRemixTernary.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerNotFound.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerNamespaced.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerMemberExpression.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerIdentifierElement.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerEarlyReturn.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerAlreadyWrapped.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/jsx-wrapper/containerAliasedImport.tsx New JSX wrapper fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/uninitializedLet.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/typedArray.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/nonArrayInit.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/multipleDeclarators.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/importPresentNoCall.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/identifierInit.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/existingArray.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/emptyArray.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/decoyConst.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/alreadyRegistered.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-middleware/absent.ts New Hydrogen middleware fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/stringLiteralKey.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/standard.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/spreadOption.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/nonObjectArg.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/nonArrayConnectSrc.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/noCall.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/memberCalleeCall.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/existingConnectSrc.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/emptyConnectSrc.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/emptyCall.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/alreadyPresent.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-csp/aliasedImport.ts New Hydrogen CSP fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/tryCatchWrapped.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/notSetCookieHeader.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/noSession.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/nonHeadersObject.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/noFunction.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/ifWrapped.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/directSet.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/differentVars.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/destructuredHeaders.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/arrowExpressionBody.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/alreadyPresentOutsideBlock.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-cookies/alreadyPresent.ts New Hydrogen cookies fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/returnObject.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/returnIdentifier.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/noReturn.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/noParams.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/noFunction.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/noFactory.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/nestedReturn.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/destructuredParam.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/destructuredContextId.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/croctStringLiteralKey.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/croctAlreadyOnObject.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/awaitedContext.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/alreadyWired.ts New Hydrogen context fixture.
test/application/project/code/transformation/fixtures/hydrogen-context/aliasedFactory.ts New Hydrogen context fixture.
test/application/project/code/generation/slot/hydrogenExampleGenerator.test.ts New Hydrogen example generator tests.
test/application/project/code/generation/slot/snapshots/hydrogenExampleGenerator.test.ts.snap Snapshots for Hydrogen route example generation.
src/infrastructure/application/validation/partialComposerLockValidator.ts Tightens lock schema to only validate provide (affects version resolution).
src/infrastructure/application/cli/cli.ts Wires Hydrogen platform, SDK, formatter, server parsers, and required codemod behavior.
src/infrastructure/application/api/graphql/workspace.ts Normalizes Hydrogen to React for API platform reporting.
src/application/project/server/provider/parser/hydrogenCommandParser.ts New Hydrogen dev command parser for server detection.
src/application/project/sdk/plugVueSdk.ts Updates failure messaging to provide manual instructions on codemod failure.
src/application/project/sdk/plugSymfonySdk.ts Updates failure messaging to provide manual instructions on codemod failure.
src/application/project/sdk/plugReactSdk.ts Updates failure messaging to provide manual instructions on provider setup failure.
src/application/project/sdk/plugNuxtSdk.ts Updates failure messaging to provide manual instructions on config failure.
src/application/project/sdk/plugHydrogenSdk.ts New Hydrogen SDK implementation (env vars, codemod tasks, example generation).
src/application/project/sdk/plugDrupalSdk.ts Adds “failed” state handling for settings include codemod.
src/application/project/packageManager/composerPackageManager.ts Simplifies Composer lock typing and removes lock-based version lookup (regression risk).
src/application/project/import/nodeImportResolver.ts Adds resolveImport (specifier → file) support with tsconfig alias probing.
src/application/project/import/lazyImportResolver.ts Forwards new resolveImport method to the underlying resolver.
src/application/project/import/importResolver.ts Extends ImportResolver interface with resolveImport.
src/application/project/code/transformation/php/symfonyBundleCodemod.ts Adds required option and throws when anchor is missing.
src/application/project/code/transformation/php/drupalLocalSettingsCodemod.ts Adds required option and throws when input is empty.
src/application/project/code/transformation/javascript/vueStoryblokCodemod.ts Adds required option and throws on missing anchors/import/calls.
src/application/project/code/transformation/javascript/vuePluginCodemod.ts Adds required option and throws when Vue app init is missing.
src/application/project/code/transformation/javascript/viteConfigPluginCodemod.ts New codemod to register a Vite plugin in Vite config exports.
src/application/project/code/transformation/javascript/utils/spreadAsArray.ts New helper for safe “normalize to array” spreads.
src/application/project/code/transformation/javascript/utils/getImportSource.ts New helper for import specifier discovery by imported name.
src/application/project/code/transformation/javascript/storyblokInitCodemod.ts Adds required option and simplifies import local-name lookup.
src/application/project/code/transformation/javascript/nuxtConfigModuleCodemod.ts Adds required option and normalizes non-array modules into arrays.
src/application/project/code/transformation/javascript/nextJsProxyCodemod.ts Adds unused required?: boolean to configuration type.
src/application/project/code/transformation/javascript/jsxWrapperCodemod.ts Adds container wrapping support, alias-aware matching, and required-mode throwing.
src/application/project/code/transformation/javascript/hydrogenMiddlewareCodemod.ts New codemod to register Hydrogen middleware export.
src/application/project/code/transformation/javascript/hydrogenCspCodemod.ts New codemod to extend Hydrogen CSP connectSrc.
src/application/project/code/transformation/javascript/hydrogenCookiesCodemod.ts New codemod to write cookies after session Set-Cookie anchor.
src/application/project/code/transformation/javascript/hydrogenContextCodemod.ts New codemod to expose croct on Hydrogen load context (Remix era).
src/application/project/code/generation/slot/reactExampleGenerator.ts Refactors rendering snippet method into a reusable static helper.
src/application/project/code/generation/slot/hydrogenExampleGenerator.ts New Hydrogen route example generator (React Router vs Remix imports).
src/application/model/platform.ts Adds HYDROGEN platform enum and display name.
Comments suppressed due to low confidence (1)

src/infrastructure/application/validation/partialComposerLockValidator.ts:13

  • ComposerLock is now validated without name/version. This prevents using composer.lock as the authoritative source of installed package versions (which is important because vendor composer.json often omits version). If the intent is to keep supporting semver checks, consider allowing name/version as optional fields here so lock-based version resolution can be reintroduced safely.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/application/project/packageManager/composerPackageManager.ts
Comment on lines +27 to +31
@@ -28,6 +28,7 @@ export type ProxyConfiguration = {
proxyFactoryName: string,
proxyName: string,
},
required?: boolean,
Comment on lines +22 to +34
const baseOptions: Configuration = {
typescript: true,
framework: 'react-router',
routeFilePath: 'app/routes/%slug%.tsx',
routeComponentName: '%name%Route',
};

const variants: Array<{label: string, options: Partial<Configuration>}> = [
{label: 'react-router-ts', options: {framework: 'react-router', typescript: true}},
{label: 'react-router-js', options: {framework: 'react-router', typescript: false}},
{label: 'remix-ts', options: {framework: 'remix', typescript: true}},
{label: 'remix-js', options: {framework: 'remix', typescript: false}},
];
@marcospassos marcospassos merged commit f268d9a into master Jun 18, 2026
6 of 7 checks passed
@marcospassos marcospassos deleted the hydrogen branch June 18, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants