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

[Bug?]: New solid start doesn't work with yarn berry #1177

Open
2 tasks done
danieltroger opened this issue Dec 25, 2023 · 54 comments
Open
2 tasks done

[Bug?]: New solid start doesn't work with yarn berry #1177

danieltroger opened this issue Dec 25, 2023 · 54 comments
Labels
bug Something isn't working vinxi related to vinxi yarn berry

Comments

@danieltroger
Copy link
Contributor

danieltroger commented Dec 25, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

daniel@mmmmmmmmmm my-app % yarn
➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ @esbuild/android-arm64@npm:0.19.10: No candidates found
➤ YN0000: └ Completed in 1s 720ms
➤ YN0000: · Failed with errors in 1s 730ms

Expected behavior 🤔

yarn install should complete successfully

Steps to reproduce 🕹

Follow this terminal log:

daniel@mmmmmmmmmm test % npm init solid@latest
Need to install the following packages:
create-solid@0.4.2
Ok to proceed? (y) y

create-solid version 0.4.0-alpha.0

Welcome to the SolidStart setup wizard!

There are definitely bugs and some feature might not work yet.
If you encounter an issue, have a look at https://github.com/solidjs/solid-start/issues and open a new one, if it is not already tracked.

✔ Where do you want to create the app? … my-app
✔ Which template do you want to use? › bare
✔ Server Side Rendering? … yes
✔ Use TypeScript? … yes
found matching commit hash: be388d58737ced31b0ed78cd8128f83c2b0a319b
downloading https://github.com/solidjs/solid-start/archive/be388d58737ced31b0ed78cd8128f83c2b0a319b.tar.gz to /Users/daniel/.degit/github/solidjs/solid-start/be388d58737ced31b0ed78cd8128f83c2b0a319b.tar.gz
extracting /examples/bare from /Users/daniel/.degit/github/solidjs/solid-start/be388d58737ced31b0ed78cd8128f83c2b0a319b.tar.gz to /private/tmp/test/my-app/.solid-start
cloned solidjs/solid-start#main to /private/tmp/test/my-app/.solid-start
✔ Copied project files

Next steps:
  1: cd my-app
  2: npm install
  3: npm run dev -- --open

To close the dev server, hit Ctrl-C
^C
daniel@mmmmmmmmmm test % cd my-app 
daniel@mmmmmmmmmm my-app % rm -rf node_modules package-lock.json 
daniel@mmmmmmmmmm my-app % yarn set version berry
warning package.json: No license field
(node:22152) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
➤ YN0000: Retrieving https://repo.yarnpkg.com/4.0.2/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.0.2.cjs
➤ YN0000: Done in 0s 675ms
daniel@mmmmmmmmmm my-app % yarn
➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ @esbuild/android-arm64@npm:0.19.10: No candidates found
➤ YN0000: └ Completed in 4s 230ms
➤ YN0000: · Failed with errors in 4s 238ms

Context 🔦

I want to use the latest version of yarn which is fast and also supports yarn link so I can link my locally built packages.

Your environment 🌎

Node v21.5.0 on macOS 14.2.1 (23C71)
M1 Max 16" MacBook Pro
@danieltroger danieltroger added the bug Something isn't working label Dec 25, 2023
@danieltroger danieltroger changed the title [Bug?]: New solid start doesn't work with yatn berry [Bug?]: New solid start doesn't work with yarn berry Dec 25, 2023
@lxsmnsyc
Copy link
Member

If we are basing it on the esbuild log, then this is an esbuild issue, not SolidStart's. Pardon me because I don't see anything related to SolidStart's setup.

@birkskyum
Copy link
Contributor

@danieltroger I get this

➜ yarn add @esbuild/android-arm64
➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @esbuild/android-arm64@npm:0.19.10
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ A package was added to the project (+ 9.37 MiB).
➤ YN0000: └ Completed in 1s 99ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 1s 140ms

This could be related to the environment / hardware / os you use, and the compatibility with that, yarn berry and @esbuild/android-arm64. It's probably best to open an issue on it in here: https://github.com/evanw/esbuild/issues with as much information about your setup as possible

@danieltroger
Copy link
Contributor Author

danieltroger commented Dec 25, 2023

@birkskyum thanks for testing. For some reason it now works flawlessly - yarn install succeeds. Must have been a fluke.

However, now when doing yarn dev I run into this:

daniel@mmmmmmmmmm my-app % yarn dev
Error: Package subpath './lib/chunks' is not defined by "exports" in /Users/daniel/.yarn/berry/cache/vinxi-npm-0.0.54-94f4086925-10c0.zip/node_modules/vinxi/package.json imported from /private/tmp/test/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/
Require stack:
- /private/tmp/test/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/client.js
    at require$$0.Module._resolveFilename (/private/tmp/test/my-app/.pnp.cjs:12657:13)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at _resolve (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:251148)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:253746)
    at /private/tmp/test/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/client.js:3:15
    at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)
    at /private/tmp/test/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/plugin.js:3:15
    at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)

Let me know if it doesn't happen for you

@birkskyum
Copy link
Contributor

birkskyum commented Dec 25, 2023

@danieltroger , when i use yarn 1.x it works alright (both install and dev server), but with berry I always have a new package failing to install, like:

➜ yarn  
➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ npm-run-path@npm:^5.1.0: No candidates found
➤ YN0000: └ Completed in 0s 475ms
➤ YN0000: · Failed with errors in 0s 487ms

or deleting node modules and retrying:

➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ lru-cache@npm:^10.0.2: No candidates found
➤ YN0000: └ Completed in 5s 713ms
➤ YN0000: · Failed with errors in 5s 722ms

so it looks like to me that yarn berry is flaky.

@lxsmnsyc
Copy link
Member

berry has a different module resolution so it may or may not be Berry's fault.

@danieltroger
Copy link
Contributor Author

I've never seen this flake before in yarn 3+ and I've been using it professionally for ~2 years 😅 Maybe that's because we have enableGlobalCache: false in most work projects' .yarnrc.yml?

It seems like there's an issue for it already: yarnpkg/berry#5989
Can you try if rm -rf ~/.yarn/berry/metadata/npm solves it for you and then look into Error: Package subpath './lib/chunks' is not defined by "exports" or do you want me to open a separate issue for that?

@birkskyum
Copy link
Contributor

i tried deleting all the yarn things:

  • .yarnrc.yml,
  • .yarn folder
  • "packageManager": "yarn@4.0.2" in package.json

I then ran:

  • yarn set version berry
  • yarn

My result was:

➜ yarn
➤ YN0087: Migrated your project to the latest Yarn version 🚀

➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ npm-run-path@npm:^5.1.0: No candidates found
➤ YN0000: └ Completed in 1s 989ms
➤ YN0000: · Failed with errors in 2s 1ms

@danieltroger
Copy link
Contributor Author

danieltroger commented Dec 26, 2023

Did you also delete the yarn folder in your home directory? ~/.yarn/berry/metadata/npm

~ means your home folder, so $HOME

@birkskyum
Copy link
Contributor

oh way, the on in ~/.yarn I missed! now I get:

➜ yarn
➤ YN0065: Yarn will periodically gather anonymous telemetry: https://yarnpkg.com/advanced/telemetry
➤ YN0065: Run yarn config set --home enableTelemetry 0 to disable

➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @solidjs/meta@npm:0.29.3, @solidjs/router@npm:0.10.5, @solidjs/start@npm:0.4.2, solid-js@npm:1.8.7, and 621 more.
➤ YN0000: └ Completed in 7s 937ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 559 packages were added to the project (+ 168.09 MiB).
➤ YN0000: └ Completed in 2s 624ms
➤ YN0000: ┌ Link step
➤ YN0007: │ esbuild@npm:0.18.20 must be built because it never has been before or the last one failed
➤ YN0007: │ esbuild@npm:0.19.10 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 2s 62ms
➤ YN0000: · Done in 12s 684ms

@danieltroger
Copy link
Contributor Author

Epic, it worked! Now try yarn dev

@birkskyum
Copy link
Contributor

birkskyum commented Dec 26, 2023

Hello world counter works as expected

➜ yarn dev
start {
  appRoot: './src',
  ssr: true,
  islands: false,
  server: { base: undefined },
  solid: {}
}
vinxi hook app:config-resolved                                                                                                 11:43:09 AM
vinxi hook app:created                                                                                                         11:43:10 AM
vinxi Found vite.config.js with app config
/*404
/
/*404
/

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

@danieltroger
Copy link
Contributor Author

Whaatt, I'll also try clearing all my caches then

@danieltroger
Copy link
Contributor Author

What's your node version btw?

@birkskyum
Copy link
Contributor

v18.19.0

@danieltroger
Copy link
Contributor Author

Can you try on latest? My node install is bricked by trying to get asdf to work to get old solid start docs to work because I needed to read them because I couldn't update because of this so I need to fix my node before I can get back to reproducing

@birkskyum
Copy link
Contributor

birkskyum commented Dec 26, 2023

sure, I swapped to node 20.10.0 using nvm and ran yarn, yarn dev, and it starts the dev server alright as well.

@danieltroger
Copy link
Contributor Author

Interesting, what about 21.5.0?

@birkskyum
Copy link
Contributor

checked just now - 21.5.0 works as well for me.

@birkskyum
Copy link
Contributor

I tried adding the Vite 5 resolution as well:

  "resolutions": {
    "vite": "5"
  },

that that works as well for me. both dev build and start

@danieltroger
Copy link
Contributor Author

Soo weird. I'm back on 21.5.0 now. Deleted ~/.yarn/berry/metadata/npm as well as ~/.yarn/berry/cache and re-did the solid start setup along with yarn setup and yarn dev still gives me

daniel@mmmmmmmmmm my-app % yarn dev
Error: Package subpath './lib/chunks' is not defined by "exports" in /Users/daniel/.yarn/berry/cache/vinxi-npm-0.0.54-94f4086925-10c0.zip/node_modules/vinxi/package.json imported from /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/
Require stack:
- /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/client.js
    at require$$0.Module._resolveFilename (/private/tmp/solid-start-x/my-app/.pnp.cjs:12657:13)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at _resolve (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:251148)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:253746)
    at /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/client.js:3:15
    at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)
    at /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/plugin.js:3:15
    at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)

@danieltroger
Copy link
Contributor Author

Can you send me your yarn.lock?

@birkskyum
Copy link
Contributor

yarn.lock.zip

@danieltroger
Copy link
Contributor Author

danieltroger commented Dec 26, 2023

Thanks, here's my whole directory if running yarn dev in there gets you the same error? Contains the vite 5 resolution but still same error

my-app.zip

@danieltroger
Copy link
Contributor Author

Same issue even with your lockfile 🤨 this is peak weird. Do you think it'd be more helpful if I tried to dig into the actual issue or created a Dockerfile that reproduces the issue for you?

@danieltroger
Copy link
Contributor Author

danieltroger commented Dec 26, 2023

WAIT, you don't happen to get a node_modules folder for some reason? Can you set nodeLinker: pnp in your .yarnrc.yml to force yarn to use pnp?

@birkskyum
Copy link
Contributor

birkskyum commented Dec 26, 2023

it seems like I was able to reproduce your error when using the bare template. What I have been able to run so far was the basic template that includes the router (apparently didn't read your reproduction steps closely enough, but it became clear by comparing to the zip you shared).

@danieltroger
Copy link
Contributor Author

Niiice! I could have been clearer with this choice in my initial bug report, sorry for that.

What I've figured out so far is that

  1. This is from where the failing import comes
Screenshot 2023-12-26 at 12 10 50 2. `lib/chunks` is declared in `vinxi`s package.json#exports map Screenshot 2023-12-26 at 12 11 24

This means something's up with the module resolution probably

The stack printed by the error message contains suspiciously little yarn module resolution, currently looking into what jiti is as that seems sus

at require$$0.Module._resolveFilename (/private/tmp/solid-start-x/my-app/.pnp.cjs:12701:13)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at _resolve (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:251148)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:253746)
    at /private/tmp/solid-start-x/my-app/.yarn/unplugged/@vinxi-server-functions-virtual-824b5314c0/node_modules/@vinxi/server-functions/client.js:3:15
    at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)
    at /private/tmp/solid-start-x/my-app/.yarn/unplugged/@vinxi-server-functions-virtual-824b5314c0/node_modules/@vinxi/server-functions/plugin.js:3:15
    at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
    at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)

@birkskyum
Copy link
Contributor

It's holding back deno support as well

@danieltroger
Copy link
Contributor Author

danieltroger commented Dec 26, 2023

@birkskyum Ok so I debugged it all the way, seems like indeed jiti is to blame.

The issue is this: the import import { chunkify } from "vinxi/lib/chunks"; in @vinxi/server-functions should resolve to this condition:

Screenshot 2023-12-26 at 12 41 52

However it doesn't, because jiti does not provide the correct conditions in the resolve request here, it should be an array that includes "import":
Screenshot 2023-12-26 at 12 42 34

This causes yarn to fallback to its defaultExportsConditions (["node", "require"])
Screenshot 2023-12-26 at 12 43 42

Which means it doesn't find anything in package.json#exports in resolvePackageTarget
Screenshot 2023-12-26 at 12 44 37

Hacky workaround that might work in this specific case and break other things would be to slap a yarn patch onto vinxi that duplicates the import condition into one called node or require.

@birkskyum can you take it from here with opening a relevant issue at vinxi or jiti? I need to eat something and then continue building a website. Lmk if you need more details, I have a screen recording of the debugging session

@nksaraf
Copy link
Member

nksaraf commented Dec 28, 2023

But we probably don't want it to fallback to nativeRequire. We are only shipping ESM code. So it needs to be picked up using ESM imports. Jiti is there for typescript support in the app.config file. One optimization can be to remove Jiti for just JS files since they should be native node compatible. but i'm worried yarn berry is doong something with placing files weirdly in node_modules that makes typical resolve algorithms miss this. It should have been found in the block above your breakpoint.

@nksaraf
Copy link
Member

nksaraf commented Dec 28, 2023

Also is there something better I can use than jiti for loading our config files which might be ts? Should I go the vite route and bundle the config file with esbuild first?

@nksaraf
Copy link
Member

nksaraf commented Dec 28, 2023

nksaraf/vinxi#60 should help with js config files.

@nksaraf
Copy link
Member

nksaraf commented Dec 28, 2023

Latest vinxi release (0.0.58) should have fixed this if you vite.config file is a js file and not ts.

@danieltroger
Copy link
Contributor Author

danieltroger commented Dec 28, 2023

It should have been found in the block above your breakpoint.

In what screenshot?

Latest vinxi release (0.0.58) should have fixed this if you vite.config file is a js file and not ts.

Great, thanks. I think this is a good workaround for now but it would be even better with a more long-term fix, given that solid-start has a vite.config.ts file by default. Maybe Jiti could fix their code to request the import condition instead?

Also I'm now getting

daniel@mmmmmmmmmm my-app % yarn dev
vinxi 0.0.59
start {
  appRoot: './src',
  ssr: true,
  islands: false,
  server: { base: undefined },
  solid: {}
}
vinxi Found vite.config.js with app config
vinxi starting dev server

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

9:22:08 PM [vite] Internal server error: require is not defined
  Plugin: vite-server-references
  File: /private/tmp/solid-start-x/my-app/.yarn/__virtual__/vite-virtual-b448d2bb92/5/Users/daniel/.yarn/berry/cache/vite-npm-5.0.10-8371795915-10c0.zip/node_modules/vite/dist/client/client.mjs
      at parseAdvanced (file:///private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-plugin-directives-virtual-997431b763/5/Users/daniel/.yarn/berry/cache/@vinxi-plugin-directives-npm-0.0.50-1730f06c02-10c0.zip/node_modules/@vinxi/plugin-directives/parse.js:22:13)
      at Object.transform (file:///private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-plugin-directives-virtual-997431b763/5/Users/daniel/.yarn/berry/cache/@vinxi-plugin-directives-npm-0.0.50-1730f06c02-10c0.zip/node_modules/@vinxi/plugin-directives/shim-exports.js:26:14)
      at TransformContext.transform (file:///private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-plugin-directives-virtual-997431b763/5/Users/daniel/.yarn/berry/cache/@vinxi-plugin-directives-npm-0.0.50-1730f06c02-10c0.zip/node_modules/@vinxi/plugin-directives/plugin.js:49:29)
      at Object.transform (file:///private/tmp/solid-start-x/my-app/.yarn/__virtual__/vite-virtual-b448d2bb92/5/Users/daniel/.yarn/berry/cache/vite-npm-5.0.10-8371795915-10c0.zip/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:63705:62)
      at async loadAndTransform (file:///private/tmp/solid-start-x/my-app/.yarn/__virtual__/vite-virtual-b448d2bb92/5/Users/daniel/.yarn/berry/cache/vite-npm-5.0.10-8371795915-10c0.zip/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:49386:29)
      at async viteTransformMiddleware (file:///private/tmp/solid-start-x/my-app/.yarn/__virtual__/vite-virtual-b448d2bb92/5/Users/daniel/.yarn/berry/cache/vite-npm-5.0.10-8371795915-10c0.zip/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:58987:32)

Instead. Anyone know what that could be?

@nksaraf
Copy link
Member

nksaraf commented Dec 29, 2023

I think a new solid-start release is needed with the internal deps fixed. The plugin directives needs to be bumped with the fixed version. @ryansolid

@danieltroger
Copy link
Contributor Author

@nksaraf I bumped vinxi with resolutions in my package.json so the issue I posted above is another, new one.

daniel@mmmmmmmmmm pb2 % yarn why vinxi
└─ pb2@workspace:.
   └─ vinxi@npm:0.0.64 (via npm:0.0.64)

I'll try to dig into that one now because I have HMR issues with css files in old solid-start and maybe it's fixed in the new one.

@danieltroger
Copy link
Contributor Author

Holy hell, if this was what you meant with "fixing internal deps" then that + renaming vite.config.ts to vite.config.js indeed did the trick! 🥳

"resolutions": {
    "vite": "5",
    "vinxi": "0.0.64",
    "@vinxi/plugin-directives": "0.0.60"
  }

@lxsmnsyc
Copy link
Member

lxsmnsyc commented Jan 4, 2024

I've also suggested moving Vinxi to 1.0 to fix the resolution since 0.0.x doesn't follow the same scheme as >0.1.x

@nksaraf
Copy link
Member

nksaraf commented Jan 4, 2024

I'll do the shift within this week. Just want to get done with all the bugs that have already been filed

@ryansolid
Copy link
Member

Ok new SolidStart is released at 0.4.3. Not sure that changes anything but thought I'd let you all know.

@ryansolid ryansolid added the vinxi related to vinxi label Jan 5, 2024
@birkskyum
Copy link
Contributor

just tested, the issue persist with 0.4.3 and these "no candidate found" errors:

➜ yarn
➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ @esbuild/android-arm64@npm:0.19.11: No candidates found
➤ YN0000: └ Completed in 3s 773ms
➤ YN0000: · Failed with errors in 3s 783ms

@danieltroger
Copy link
Contributor Author

@birkskyum but that was just the yarn glitch, right? Do rm -rf ~/.yarn/berry/metadata/npm to get past that

@birkskyum
Copy link
Contributor

@danieltroger , oh yes forgot about that - I get this on yarn installation:

➜ yarn
➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @solidjs/start@npm:0.4.3, solid-js@npm:1.8.8, vinxi@npm:0.1.1, @ampproject/remapping@npm:2.2.1, and 647 more.
➤ YN0000: └ Completed in 7s 183ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 585 packages were added to the project (+ 179.13 MiB).
➤ YN0000: └ Completed in 5s 114ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ esbuild@npm:0.18.20 must be built because it never has been before or the last one failed
➤ YN0007: │ esbuild@npm:0.19.11 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 1s 188ms
➤ YN0000: · Done with warnings in 13s 555ms

and on yarn run dev

➜ yarn run dev 
vinxi 0.1.1
Error: Package subpath './lib/chunks' is not defined by "exports" in /Users/admin/.yarn/berry/cache/vinxi-npm-0.1.1-32d0d0bf47-10c0.zip/node_modules/vinxi/package.json imported from /Users/admin/repos/solid-kitchen/my-app-bare-4.3/.yarn/__virtual__/@vinxi-server-functions-virtual-d4c1e43827/4/.yarn/berry/cache/@vinxi-server-functions-npm-0.1.0-39311db440-10c0.zip/node_modules/@vinxi/server-functions/
Require stack:
- /Users/admin/repos/solid-kitchen/my-app-bare-4.3/.yarn/__virtual__/@vinxi-server-functions-virtual-d4c1e43827/4/.yarn/berry/cache/@vinxi-server-functions-npm-0.1.0-39311db440-10c0.zip/node_modules/@vinxi/server-functions/client.js
    at require$$0.Module._resolveFilename (/Users/admin/repos/solid-kitchen/my-app-bare-4.3/.pnp.cjs:13149:13)
    at Function.resolve (node:internal/modules/helpers:136:19)

@danieltroger
Copy link
Contributor Author

danieltroger commented Jan 5, 2024

@birkskyum nice! Really appreciate you testing this end-to end. The issue you got now is the one you get past by renaming vite.config.ts to vite.config.js.

  1. Do you want to go and complain to jiti about this? Maybe they can do something about not resolving the correct export. I already hate not being able to go-to-definition on the things in my vite config file to check the type definitions, would appreciate if a ts config file worked.
  2. Apart from (1) everything will work until you try to build, which is when you'll run into this https://discord.com/channels/722131463138705510/910635844119982080/1192784902953914388, I think @nksaraf promised to look at that

@danieltroger
Copy link
Contributor Author

Hi @nksaraf, did you have time to look into why it's not possible to build (https://github.com/danieltroger/vinxi-repro)?

@danieltroger
Copy link
Contributor Author

I opened unjs/jiti#204 and unjs/mlly#221. Seems like mlly is a completely homegrown module resolver that has absolutely no idea of yarn berry so it's going to be interesting to see how this develops. @nksaraf do you know why solid-start needs mlly?

In the meantime I made a patch that can be applied via yarn patch. Technically it could result in the wrong modules being resolved but I don't care because solid-start builds using it:

  1. Put below file into .yarn/patches
mlly-npm-1.5.0-dc7923db5f.patch
diff --git a/dist/index.mjs b/dist/index.mjs
index 14926284e7efa76777a1bbb819570fd5b9c27744..7733a0b8963f3393780caf85ecdd8d89ee802779 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -2109,7 +2109,16 @@ function _resolve(id, options = {}) {
   return pathToFileURL(realPath).toString();
 }
 function resolveSync(id, options) {
-  return _resolve(id, options);
+  try {
+    return _resolve(id, options);
+  } catch(originalError){
+    try {
+      return import.meta.resolve(id);
+    } catch(nativeResolveError){
+      console.log("Backup resolution using native node resolution failed.", nativeResolveError);
+      throw originalError;
+    }
+  }
 }
 function resolve(id, options) {
   return pcall(resolveSync, id, options);

2. Add this to `"resolutions"` in your package.json:
"mlly@npm:^1.2.0": "patch:mlly@npm%3A1.5.0#~/.yarn/patches/mlly-npm-1.5.0-dc7923db5f.patch",
"mlly@npm:^1.4.2": "patch:mlly@npm%3A1.5.0#~/.yarn/patches/mlly-npm-1.5.0-dc7923db5f.patch",
  1. Run yarn install

@pi0
Copy link

pi0 commented Jan 16, 2024

I would be happy to help investigating any upstream compatibility issues within UnJS ecosystem but highly appreciate making minimal reproductions to investigate 🙏🏼

@pi0
Copy link

pi0 commented Jan 16, 2024

Some notes here: unjs/jiti#204 (comment)

TLDR: While this is a complex issue, there are some things can help to resolve issues faster in solid/vinxi side:

  • Using "default" condition + type: "module"
  • Make /config subpath a type-only util that not only solves this issue, but hugely improves DX and loading speed
  • There seems more pnpm issues like vite should be either an explicit dependency or peerDependency

@nksaraf
Copy link
Member

nksaraf commented Jan 17, 2024

I don't know how much loading speed will be helped by making config a type only util. The things it imports (mostly lazily) are also going to be imported anyway during load to start the app. Make the entry point runnable is desirable for an architecture that is meant to be totally in the users control.

Mlly and jiti are right now used for running typescript config files. I am probably going to go the way of vite and use esbuild to quickly transpile the config file .. and then load that.

@nksaraf
Copy link
Member

nksaraf commented Jan 17, 2024

Vite is a direct dependency of Vinxi. Does solid start also need to make it a dependency ?

@birkskyum
Copy link
Contributor

birkskyum commented Jan 17, 2024

Would it make sense to make solidjs/start depend on vinxi which depended on vite, instead of installing vinxi / @solidjs/start separate in each repo? or does that become too restrictive somehow

@pi0
Copy link

pi0 commented Jan 17, 2024

don't know how much loading speed will be helped by making config a type only util.

Try JITI_DEBUG=1 to see what happens when loading config. It is no different than when using esbuild or any native import it has same overhead for each load/reload. Also jiti at least for Nitro and Nuxt is not a TS helper! It allows more like config reloads. You don't quickly transpile config file but all of the dependencies inside /config subpath at least will be loaded.

Anyway, if you like to go with a less consistent way with Nitro and UnJS ecosystem, that's your decision ;)

Does solid start also need to make it a dependency ?

Yes, for string pnp any dependency should be explicitly defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vinxi related to vinxi yarn berry
Projects
None yet
Development

No branches or pull requests

6 participants