-
Notifications
You must be signed in to change notification settings - Fork 438
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
tinycolor is not a function #249
Comments
Oh no, I had tested this in #245 but apparently not well enough. I will roll this back in a 1.5.1 and we can try to debug. Can you share any more details or a STR? |
I'll deploy a new version out of 1.4.2-branch |
@Babyfaceqian I just published 1.5.1 which should match 1.4.2 |
Can you confirm it's working again? |
Also, which version of node are you using? |
1.5.1 works. |
@Babyfaceqian I set this test case up on https://runkit.com/embed/kzh7l5l3wocg and it seems to work. Any chance you can send me a test case / repo where this is failing? |
@Babyfaceqian I published a beta version as 1.6.0, can you please check that? https://www.npmjs.com/package/tinycolor2?activeTab=versions. It can be installed with |
Checked on runkit with the beta, going back to Node 4.0: https://runkit.com/embed/fdd1jg4lfegd
Returns |
@bgrins Sorry for the late response. |
Were you loading it with a CDN like https://cdn.jsdelivr.net/npm/tinycolor2/ or https://cdnjs.cloudflare.com/ajax/libs/tinycolor/, or directly from npm? And if from npm can you share what scripts you were using to build for the browser? It's possible |
let me try |
@bgrins tinycolor2@1.6.0-beta.2 doesn't works.
|
@bgrins I saw below code in the package.json of
|
Thanks for looking into it. I didn't realize it had to specify a browser export specifically - tbh the config and docs for it are not very clear to me. Would I also need a sibling to
or just the exports > . > browser? |
As per https://nodejs.org/api/packages.html#conditional-exports maybe we need a |
Alright, published a beta 3 with the default export section at https://www.npmjs.com/package/tinycolor2/v/1.6.0-beta.3?activeTab=explore. Can you try that with your setup? |
Alright, tried publishing a beta 4 with the "browser" field in package.json (https://www.npmjs.com/package/tinycolor2/v/1.6.0-beta.4?activeTab=explore) |
Though it seems like the build tool is picking up the module export somehow |
I also went ahead and published a beta 5 which changed the order of the exports to try putting require first https://www.npmjs.com/package/tinycolor2/v/1.6.0-beta.5?activeTab=explore |
Let me know if 4 or 5 fixes it |
@bgrins 4 fail, trying 5 |
5 same as before |
Let me try another build tool |
Yeah I was wondering if there was any way to get debugging output from the build tool. It seems to be either grabbing |
The fact that it was working before (when we weren't exporting ESM makes me think it's the former - grabbing |
I know it's a totally different setup, but here's it working in the browser with parcel & ESM https://codesandbox.io/s/determined-meadow-6tip3b?file=/src/index.js |
alright, i will create demo and send you tomorrow to keep looking into. It's too late here:) |
@bgrins Plz check this demo: https://codesandbox.io/s/umi-demo-x8cfqf?file=/src/pages/index.tsx I also digged into I also tried to changed the configs in package.json of tinycolor2, and found one way to fix this by adding |
@Babyfaceqian thanks for making that sandbox and digging into the problem, I can reproduce the problem there. I did try adding a
From https://www.npmjs.com/package/tinycolor2/v/1.6.0-beta.6?activeTab=explore |
I do notice that in index.tsx you have
(mixing require and import). Is it possible the build tool is confused by this? It seems to work fine I change it to:
|
Although it seems to work alright with |
Maybe it is working with beta6 after all and it just wasn't re-running in code sandbox? It appears to be working for me now. Lmk if beta6 is good for you when you have a chance. If so I can add that |
@bgrins I also see it is working in your code sandbox, beta6 is good for me, you may add |
… of a build tool using the ESM export, and does not seem to negatively affect other tools which ignore this in lieu of the exports section - see for example https://webpack.js.org/guides/package-exports/. Fixes #249
… of a build tool using the ESM export, and does not seem to negatively affect other tools which ignore this in lieu of the exports section - see for example https://webpack.js.org/guides/package-exports/. Fixes #249 (#259)
Alright, I added the field in the main branch, and have published a 1.6.0-beta.8 from it. I'll push an official new version out in the next day or two. |
@Babyfaceqian I've pushed out https://www.npmjs.com/package/tinycolor2/v/1.5.2, let me know if there are issues with that. |
import tinycolor2 from 'tinycolor2'; // Works with v1.5.2 (updated syntax). |
Need to change the import syntax for v1.6.0. See: bgrins/TinyColor#249
I just upgraded tinycolor@1.5.0 and code like this:
It comes
tinycolor is not a function
error, plz take a look.The text was updated successfully, but these errors were encountered: