Git Product home page Git Product logo

Comments (7)

wooorm avatar wooorm commented on July 22, 2024

Can you reduce this. What values are being passed. Which things exist on disk?

I am on mac, it works.

process.cwd() + '/dummy.js' seems quite bad on your side. / doesn’t work on Windows. I’d also guess process.cwd() to be different across OSes. process.cwd() typically ends in path.sep already. path.join(process.cwd(), 'dummy.js') is how you combine paths in Node.

@ts-expect-error the types are wrong

The types here are not wrong? Your await is wrong.

from import-meta-resolve.

wooorm avatar wooorm commented on July 22, 2024

Yarn pnp linker

This sounds quite likely to be the problem too. The algorithm here is based on how Node/npm work. Yarn intentionally does things differently. Perhaps you can see things posted already in its issue tracker

from import-meta-resolve.

dcarniel-ipepper avatar dcarniel-ipepper commented on July 22, 2024

Can you reduce this. What values are being passed. Which things exist on disk?

I am on mac, it works.

process.cwd() + '/dummy.js' seems quite bad on your side. / doesn’t work on Windows. I’d also guess process.cwd() to be different across OSes. process.cwd() typically ends in path.sep already. path.join(process.cwd(), 'dummy.js') is how you combine paths in Node.

My first thought was indeed around an issue with cwd, I first changed the code to use path.join to avoid any such issue, but it didn't change a thing.

Regarding the "dummy.js", my understanding is that they (it's not my code) want to resolve a peer dependency, so they concatenate the current directory with a fictitious filename so the resolver thinks it is working for an actual file.

In the end it passes a path like /home/user/project/dummy.js and @sveltejs/kit. The only point I could see being a problem is that the "file" used as reference is not in the "src" folder of the project.

from import-meta-resolve.

dcarniel-ipepper avatar dcarniel-ipepper commented on July 22, 2024

Yarn pnp linker

This sounds quite likely to be the problem too. The algorithm here is based on how Node/npm work. Yarn intentionally does things differently. Perhaps you can see things posted already in its issue tracker

I know it behave differently, though it works on my Linux VM, plus when I change the code to use import.meta.resolve from node it works like a charm on all machines.

from import-meta-resolve.

wooorm avatar wooorm commented on July 22, 2024

(it's not my code)

It’s not my code either 😉.
In my experience, based on tests, this project works perfectly in macOS, linux, and windows: https://github.com/wooorm/import-meta-resolve/actions/runs/6734940885.
Now it’s on you to create a reduced test case showing it doesn’t!

Showing which results are generated for macos/windows/linux, and which files exist in those 3 cases, will help.

Regarding the "dummy.js"

It’s because .cwd() points to a folder.
resolve works from files.
Folders are also files.
But there are differences in resolving from a, a/, and a/b.js.

plus when I change the code to use import.meta.resolve

I believe there are specific things that yarn does for pnp to hook into import.meta.resolve. If you search for “yarn pnp import.meta.resolve” you’ll find sveltejs/kit#11578 (comment) for example

from import-meta-resolve.

dcarniel-ipepper avatar dcarniel-ipepper commented on July 22, 2024

Okay I thought changing this specific call was a clear enough indicator that the code performed differently on different environments, if you don't feel like looking into it, I'll see if I have some time to create a more "isolated" reproducer.

from import-meta-resolve.

wooorm avatar wooorm commented on July 22, 2024

See also #10

from import-meta-resolve.

Related Issues (18)

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.