Skip to content

Conversation

@adamjanicki2
Copy link
Contributor

Currently, to import Treecle via ESM, after npm installing, you have to write

import Treecle from "treecle/dist/treecle.js"

but it would be nice if you could just do

import Treecle from "treecle"

so this fix just adds an index.js to the output dist directory so that you can do that

@adamjanicki2 adamjanicki2 requested a review from LeaVerou April 28, 2024 11:43
@netlify
Copy link

netlify bot commented Apr 28, 2024

Deploy Preview for treecle ready!

Name Link
🔨 Latest commit cbb7867
🔍 Latest deploy log https://app.netlify.com/sites/treecle/deploys/662e3678c31a8300087e96e9
😎 Deploy Preview https://deploy-preview-32--treecle.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@LeaVerou
Copy link
Member

We don't need an index.js for this, just certain package.json fields (main, exports, not sure if there are others that are relevant).

@adamjanicki2
Copy link
Contributor Author

We don't need an index.js for this, just certain package.json fields (main, exports, not sure if there are others that are relevant).

Got it, currently the relevant fields are set to

"main": "./dist/treecle.cjs",
"module": "./dist/treecle.js",

I think the issue is the build is outputting a file called treecle.cjs.js, so the target for main is off. Is the correct fix to change the package to "main": "./dist/treecle.cjs.js", or to adjust the rollup config so that it names the file treecle.cjs?

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 this pull request may close these issues.

3 participants