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

Auto resolve deno.json doesn't work right for denoLoaderPlugin #162

Open
KyleJune opened this issue Jan 1, 2025 · 3 comments
Open

Auto resolve deno.json doesn't work right for denoLoaderPlugin #162

KyleJune opened this issue Jan 1, 2025 · 3 comments

Comments

@KyleJune
Copy link

KyleJune commented Jan 1, 2025

This feature was introduced by #145.

It appears as though the plugin should just work using the auto resolved deno.json. In actuality, that only applies to the WasmWorkspace. In plugin_deno_loader.ts, configPath is also passed to the NativeLoader. The NativeLoader doesn't auto resolve deno.json. So if you try using the plugin without the configPath specified, the NativeLoader will run without your deno.json configuration. The InfoCache then ends up running deno info with the --no-config flag. For my own project, this ends up causing the latest version of react to be used instead of the version I configured in my deno.json configuration file. I think to fix the issue, deno.ts needs it's info function updated to not set the --no-config flag if a configPath wasn't specified.

@KyleJune
Copy link
Author

KyleJune commented Jan 1, 2025

Here is a screenshot demonstrating that 2 different versions of react were used despite my deno.json having a version specified with an override. the react-error-boundary package used the wrong version of react because it was going by it's package.json file instead of my projects deno.json for choosing the version of react to use.

image

I tried removing adding the --no-config arg from the info command when unspecified. It appears that isn't enough to prevent react-error-boundary to use the correct version of react. It still resulted in multiple versions of react being used. it actually didn't find my deno.json file. The plugin only works when I explicitly set the configPath.

@KyleJune
Copy link
Author

KyleJune commented Jan 1, 2025

Here is a link to the package.json for react-error-boundary that is loading a different version of react than what is specified in my deno.json file.

Here is what I first tried with the versions being specified in my deno.json file. I omitted irrelevant details.

{
  "imports": {
    "esbuild": "npm:esbuild@^0.24.0",
    "react": "npm:react@^18.0.0",
    "react-dom": "npm:react-dom@^18.0.0",
    "@types/react": "npm:@types/react@^18.0.0",
    "react-error-boundary": "npm:react-error-boundary@^5.0.0",
  }
}

Then this is what my package.json looked like when I tried seeing if the issue would be resolved by specifying overrides in a package.json file.

{
  "dependencies": {
    "esbuild": "^0.24.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "@types/react": "^18.0.0",
    "react-error-boundary": "^5.0.0",
  },
  "overrides": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "@types/react": "^18.0.0",
  }
}

@KyleJune
Copy link
Author

KyleJune commented Jan 1, 2025

I found a separate issue on the deno project for overrides not being respected (denoland/deno#26841). As a workaround for that issue, I'm going to downgrade the version of react-error-boundary so that I don't have dependencies depending on different versions of react.

I still think this auto resolve issue will need fixed though. If deno info will auto discover the deno.json file if you don't pass --no-config flag, simply removing the else for when configPath isn't set should resolve the issue to ensure it autodiscovers the deno.json file to use. If it doesn't have auto discovery, I believe this code package will need updated to have it so that deno info command is called with the correct configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant