GithubHelp home page GithubHelp logo

Comments (6)

rchl avatar rchl commented on July 19, 2024

BTW. The chain of calls that leads to this code is:

nuxi (loadKit)
->
@nuxt/kit (loadNuxt)
->
pkg-types (resolvePackageJSON)
->
mlly (resolvePath)
->
mlly (_resolve)

from mlly.

rchl avatar rchl commented on July 19, 2024

Hmm, there is more issues like that elsewhere. For example in getPackageScopeConfig which I think comes from internal Node libs. So I think the solution to issues like that is ensure that the base URL ends in slash if it's a directory.

new URL('./', 'file:///project/docs/').href
"file:///project/docs/"

from mlly.

rchl avatar rchl commented on July 19, 2024

This rabbit hole goes deep.
The first directory that is involved and that doesn't include the trailing slash is the rootDir one resolved in https://github.com/nuxt/nuxt/blob/184d57bb1923b8bf21a372eabdb67e1241d2023f/packages/nuxi/src/commands/dev.ts#L41.
Forcing trailing slash here fixes this specific issue but creates another.
So it's no longer clear to me what and where should be fixed.
It seems to me like using URI for resolving directory paths is a little brittle since it's not clear whether path is to a directory or a file without doing file IO.

from mlly.

pi0 avatar pi0 commented on July 19, 2024

Hi dear @rchl. Thanks for sharing all investigations.

Yes, that's kinda tricky situation. We removed the directory URL workaround but it introduced other regressions in Nuxt 3.

I think first good step would be making a minimal mlly reproduction to test the behavior if you can help 🙏🏼 . We might try to introduce a major version on progressively adopt it within nuxt ecosystem.

from mlly.

rchl avatar rchl commented on July 19, 2024

I think first good step would be making a minimal mlly reproduction to test the behavior if you can help 🙏🏼

I'm thinking that a unittest for that would be a good reproduction?
So something like https://github.com/unjs/mlly/blob/main/test/fixture/resolve.mjs but I guess this is just a lone file that is not really testing anything?

from mlly.

pi0 avatar pi0 commented on July 19, 2024

Yeah. We probably could make an external repo for it. Especially trying node_modules resolution too via an exclude in .gitignore and then moving it to fixtures (because previous regression happened this way).

from mlly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.