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

prool/instances is not exported in published npm package #16

Closed
L8D opened this issue Jun 14, 2024 · 11 comments
Closed

prool/instances is not exported in published npm package #16

L8D opened this issue Jun 14, 2024 · 11 comments

Comments

@L8D
Copy link

L8D commented Jun 14, 2024

Hello. I installed version 0.0.12 and the instances are available under prool/exports/instances but not under prool/instances

Cannot find module 'prool/instances' or its corresponding type declarations.
  There are types at '.../node_modules/prool/_lib/exports/instances.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'. (tsserver 2307)
@jxom
Copy link
Member

jxom commented Jun 14, 2024

Can you provide a minimal reproduction?

@L8D
Copy link
Author

L8D commented Jun 14, 2024

@jxom

mkdir foo && cd foo && npm init -y && npm install -D jest ts-jest typescript @types/jest prool && npx tsc --init && npx ts-jest config:init
cat - > myprooltest.test.ts <<EOF
import { createServer } from 'prool'
import { anvil } from 'prool/instances'

describe('my anvil server', () => {
	it('starts', async () => {
		const server = createServer({
			instance: anvil()
		})

		await server.start()
	})
})
EOF
npx jest

copy & paste into terminal and you will find the error below:

 FAIL  ./myprooltest.test.ts
  ● Test suite failed to run

    myprooltest.test.ts:2:23 - error TS2307: Cannot find module 'prool/instances' or its corresponding type declarations.

    2 import { anvil } from 'prool/instances'
                            ~~~~~~~~~~~~~~~~~

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.683 s
Ran all test suites.

@jxom
Copy link
Member

jxom commented Jun 15, 2024

Yeah Jest isn't really ESM friendly, especially with package.json#exports. Will probably need to add proxy packages so it can pick up the entrypoints 😕.

Highly recommend to use Vitest though.

@cstoneham
Copy link

FYI just ran into the same issue here :(

@WardenJakx
Copy link

Same here plz fix

@jxom
Copy link
Member

jxom commented Jun 18, 2024

PRs welcome.

@cstoneham
Copy link

cstoneham commented Jun 21, 2024

FYI I'm still seeing this issue after migrating to vitest - @jxom what's the root of this problem? Happy to look into it but would help to have some context on why you think this might be happening.

*EDIT, looks like it's a combination of these issues:
microsoft/TypeScript#33079 (comment)
microsoft/TypeScript#50058 (comment)

@cstoneham
Copy link

@L8D FYI if you're in a pinch like me I published a version rainmaker-prool which exports everything from the main export as a workaround until we get this fully figured out:

import { anvil, createServer, CreateServerReturnType } from "rainmaker-prool";

it also includes a polyfill for Promise.withResolve which you'd likely have trouble with too.
https://github.com/ungap/with-resolvers

@jxom
Copy link
Member

jxom commented Jun 22, 2024

What version of Node are you running? Prool only supports Node >=22 for now.

@jxom
Copy link
Member

jxom commented Jun 22, 2024

OP issue fixed via a879039.

@jxom jxom closed this as completed Jun 22, 2024
@cstoneham
Copy link

thanks @jxom!

QQ, how do we use this in our projects? I updated to 0.0.15 but still getting Cannot find module 'prool/instances' or its corresponding type declarations. when i try to import like this:

import { anvil } from "prool/instances";

anything I need to change?

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

No branches or pull requests

4 participants