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

Importing ESM index modules throws an error during module resolution #370

Closed
pcwiek opened this issue Jul 3, 2024 · 2 comments · Fixed by #371
Closed

Importing ESM index modules throws an error during module resolution #370

pcwiek opened this issue Jul 3, 2024 · 2 comments · Fixed by #371

Comments

@pcwiek
Copy link

pcwiek commented Jul 3, 2024

IxJS version: 6.0.0

NodeJS 22.4

Code to reproduce:

> var f = await import('ix/asynciterable/operators/index');
Uncaught:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/p/project/node_modules/ix/asynciterable/operators/ignoreelements' imported from /Users/p/project/node_modules/ix/asynciterable/operators/index.mjs
    at finalizeResolution (node:internal/modules/esm/resolve:260:11)
    at moduleResolve (node:internal/modules/esm/resolve:921:10)
    at defaultResolve (node:internal/modules/esm/resolve:1120:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:526:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///Users/p/project/node_modules/ix/asynciterable/operators/ignoreelements'
}
> var f = await import('ix/asynciterable/index');
Uncaught:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/p/project/node_modules/ix/asynciterable/includes' imported from /Users/p/project/node_modules/ix/asynciterable/index.mjs
    at finalizeResolution (node:internal/modules/esm/resolve:260:11)
    at moduleResolve (node:internal/modules/esm/resolve:921:10)
    at defaultResolve (node:internal/modules/esm/resolve:1120:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:526:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///Users/p/project/node_modules/ix/asynciterable/includes'
}

Expected behavior:

index modules resolve without issues

Actual behavior:

import fails

Additional information:

There's a workaround: do not use index files, but import specific modules separately.

For example:

import { buffer } from 'ix/asynciterable/operators/buffer';
import { catchError } from 'ix/asynciterable/operators/catcherror';
import { delay } from 'ix/asynciterable/operators/delay';
import { filter } from 'ix/asynciterable/operators/filter';
import { finalize } from 'ix/asynciterable/operators/finalize';
import { map } from 'ix/asynciterable/operators/map';
import { memoize } from 'ix/asynciterable/operators/memoize';
import { from } from 'ix/asynciterable/asynciterablex';

instead of:

import { buffer, catchError, delay, filter, finalize, map, memoize } from 'ix/asynciterable/operators/index';
import { from } from 'ix/asyncinterable/index';

Side note: Since we're already here, there's a typo in throwError module name

import { throwError } from 'ix/asynciterable/throwerrror';

There's one r too many in error 😉 It's working just fine though, and I realize that would probably be a breaking change now, so 🤷🏻

@trxcllnt
Copy link
Member

trxcllnt commented Jul 3, 2024

Thanks for the report, looks like I missed adding .js to some of the imports in the source. I'll have a PR up shortly, along with a fix for the UMD bundles that should let me test importing all the subpath exports in CI.

@trxcllnt
Copy link
Member

Fixed in ix v7.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants