Skip to content
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

Remix Vite new bindings inference is too tightly coupled #27884

Closed
1 of 4 tasks
B-Stewart opened this issue Sep 11, 2024 · 1 comment · Fixed by #27923
Closed
1 of 4 tasks

Remix Vite new bindings inference is too tightly coupled #27884

B-Stewart opened this issue Sep 11, 2024 · 1 comment · Fixed by #27923

Comments

@B-Stewart
Copy link

Current Behavior

Right now if you want to create a remix project with NX you follow the guide here: https://nx.dev/recipes/react/remix which will create a Remix "classic" application. You can then migrate this to v2/vite by adding the vite configuration https://remix.run/docs/en/main/file-conventions/vite-config

Here lies the problem.

  1. When you migrate to vite.config.ts you are supposed to remove remix.config.js files this will remove all the remix bindings per check in
    if (configFilePath.includes('remix.config')) {
    (which is expected imo)
  2. However,
    const remixConfigGlob = '**/{remix,vite}.config.{js,cjs,mjs}';
    doesn't support vite.config.ts, only vite.config.js|.mjs so now you will essentially have zero inferred dev / build commands.
  3. On top of that, even if you switch your vite config to javascript, you now also need to make sure you don't pass any extra arguments to remix. Their docs allow you to do something like remix({ ...opts }) however adding properties to that function will break the includes check here because it looks for remix() without options as a string.
    (fileContents.includes('vitePlugin()') || fileContents.includes('remix()'))

Expected Behavior

The expected behavior would be if a vite.config.ts is added to a remix project it should pick up the remix vite:dev / build commands, and also we should be able to support remix plugin options within the vite config file.

GitHub Repo

No response

Steps to Reproduce

  1. Follow the steps here: https://nx.dev/recipes/react/remix
  2. Add vite.config.ts to remix per https://remix.run/docs/en/main/file-conventions/vite-config (add it like remix({}) to mimick options passing)
  3. run nx show project {projectname} and note that there are no remix OR vite commands inferred.

Nx Report

Node           : 20.14.0
OS             : win32-x64
Native Target  : x86_64-windows
yarn           : 4.4.1

nx                 : 19.7.2
@nx/js             : 19.7.2
@nx/linter         : 19.7.2
@nx/eslint         : 19.7.2
@nx/workspace      : 19.7.2
@nx/devkit         : 19.7.2
@nx/eslint-plugin  : 19.7.2
@nx/playwright     : 19.7.2
@nx/react          : 19.7.2
@nx/remix          : 19.7.2
@nrwl/tao          : 19.7.2
@nx/vite           : 19.7.2
@nx/web            : 19.7.2
@nx/webpack        : 19.7.2
typescript         : 5.6.2
---------------------------------------
Registered Plugins:
@nx/remix/plugin
@nx/eslint/plugin
@nx/playwright/plugin
@nx/vite/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Might be able to make a PR eventually, but I think if the targeting are fixed it should work out of box with minimal changes.

There's also probably a larger conversation about migrating the remix plugin generator to use vite out of box, but I'll save that for a separate issue.

Related links:
#22613
#27330
#27713
#22086 - happens with non ts vite.config which is a workaround you have to do for this.

@Coly010 Coly010 self-assigned this Sep 16, 2024
FrozenPandaz pushed a commit that referenced this issue Sep 18, 2024
…7923)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
The Remix plugin is too strict when finding Remix Vite projects

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
The Remix plugin should be more permissive in finding Remix Vite
projects

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #27884

(cherry picked from commit a7aab61)
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants