Comments (4)
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.
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.
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.
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)
- Use `es-module-lexer` to parse ESM
- Doesn't handle exports with invalid identifiers
- `getFullCjsExports` does not resolve re-exports from external dependencies
- IITM Throws Error When an NPM Package is Not Installed in the Root Folder HOT 7
- Are sequential patched supported? HOT 6
- parentResolve is not a function HOT 1
- Should fail gracefully when exports cannot be parsed
- Explicitly named exports should be exported over `export *` exports HOT 3
- Acorn parser does not support import attributes
- SyntaxError on importing some packages when using register() HOT 13
- SyntaxError when importing a JSON file using { type: 'json' } HOT 3
- import-in-the-middle' failed to wrap 'file:///app/node_modules/@prisma/client/default.js' HOT 2
- iitm wrappers copy exported primitives HOT 1
- Update LICENSE and NOTICE
- Codify governance HOT 2
- Resolve exports for native modules
- Errors when importing vue/server-renderer
- Import in the middle breaks `drizzle-orm` exports HOT 3
- Unable to import from Vue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from import-in-the-middle.