bostrom / text-to-image

Converts text as a string to an image containing that text.
ISC License
108 stars 40 forks source link

Add export default #273

Closed wscourge closed 1 week ago

wscourge commented 1 year ago

Version of the library @next

Describe the bug export default is undefined

To Reproduce Use this sandbox.

Expected behavior import textToImage from "text-to-image" producing an object with .generate, .generateSync and all other public methods.

Screenshots N/A

Additional context N/A

Pnlvfx commented 3 weeks ago

As this package seems to be abandoned, I've recreated and fixed this error in my package.

You can install it if you want:

npm install text-to-image-2

bostrom commented 3 weeks ago

Hi @wscourge, thanks for the issue report. As @Pnlvfx says, this project hasn't seen any activity for a while mostly due to my lack of spare time with a growing family and a full day job.

However, I'm very happy to accept PRs for fixes, or even better, new collaborators on the project to keep it alive and up to date. Maybe @Pnlvfx would be interested 😉

bostrom commented 3 weeks ago

@wscourge I just released version 6.0.0 which has been tagged as @next since 2022 🙈 Everything should work more smootly in that release. Can you try and let me know?

Thanks to this little kick-in-the-butt I'm also in the progress of updating dependencies and bringing the project up to date.

jderose9 commented 2 weeks ago

I don't think the 6.0.0 modules are setup correctly. The modules are defined at the path /dist but cannot be loaded from that directory as it is not specified in the package.json

import { generate } from 'text-to-image/dist';

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist' is not defined by "exports"

If I remove the /dist path the module is not found.

bostrom commented 1 week ago

@jderose9 it should be enough to import { generate } from 'text-to-image'

Check the example at https://codesandbox.io/p/sandbox/text-to-image-v6-example-s5jegv

I even took @wscourge's example code sandbox and updated the dependency to 6.0.0 and it's working fine!

Let me know if that helps.

bostrom commented 1 week ago

@wscourge @jderose9 I had a closer look at this issue and you are right that there were some issues with the exports even in version 6.

Module resolution seems to be a very gnarly subject, and it's not really trivial to publish a package with submodules that is usable by different kinds of module resolvers while also getting TypeScript support. After some research I ended up employing the "extensionless" strategy outlined here, which ditches the dist folder in the released npm package altogether.

I'd be thrilled if you're willing to try out the newly published 7.0.0 version (tagged as text-to-image@next) and let me know if that resolves your issues. There's also a new CodeSandbox that uses this version. For TypeScript support, note that you'll need "moduleResolution": "Node16" in your tsconfig.json.

Version 7 also drops support for node < 18 and upgrades all dependencies.

jderose9 commented 1 week ago

@bostrom Thank you! 7.0.0 is working just fine for me now on node v20.17.0.

And yes, I have also found module resolution is a huge pain.. that's why I couldn't give much more feedback than it didn't work :)

bostrom commented 1 week ago

@jderose9 thanks for the feedback, I'll go ahead and make 7.0.0 stable. Closing this for now.