Giter VIP home page Giter VIP logo

Comments (4)

mohd-akram avatar mohd-akram commented on July 18, 2024 1

From my testing, the parser is only required for NODE_MAJOR == 20 && NODE_MINOR < 6. However, it's not possible to use libraries with circular dependencies (like openai) without the parser. That's why it fails below 18.19 and 20 (the threshold used to activate the parser). We seem to expect circular dependencies to fail based on v14-assert-cyclical-dependency-failure.mjs (even though regular Node.js import succeeds) so maybe this isn't a problem. Note that it fails with a code 13 error and there's some explanation for that in nodejs/node#44601.

from import-in-the-middle.

timfish avatar timfish commented on July 18, 2024 1

It's failing but with a 0 exit code :) If you add a console.log after the import it doesn't reach there.

Ah that's a shame, I missed that entirely and only noticed the tests all passing 😭

The problem seems to happen if you do that inside the cycle, which I guess because import-in-the-middle is acting as a loader, that counts.

That means we could potentially perform await import('lib') in a worker that isn't using the import-in-the-middle loader to get the exports but I guess the performance would suck. In some quick testing, the parser looks quicker than import() anyway in Node v22. I guess it's only parsing and Node is evaluating on top of that 🤷‍♂️

from import-in-the-middle.

timfish avatar timfish commented on July 18, 2024

Regular Node.js import can handle cyclic dependencies but dynamic import cannot.

Yeah it really is only the openai test that fails and needs the parser.

It's strange that the same test now passes in v22. I can't find anything in the release notes that would suggest this limitation has been removed.

from import-in-the-middle.

mohd-akram avatar mohd-akram commented on July 18, 2024

Regular Node.js import can handle cyclic dependencies but dynamic import cannot.

That doesn't seem to be strictly true. Adding const openai = await import('openai') runs fine in regular Node.js. The problem seems to happen if you do that inside the cycle, which I guess because import-in-the-middle is acting as a loader, that counts.

It's strange that the same test now passes in v22.

It's failing but with a 0 exit code :) If you add a console.log after the import it doesn't reach there.

from import-in-the-middle.

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.