-
Notifications
You must be signed in to change notification settings - Fork 522
Help test out Tippy v5! #530
Comments
@atomiks I tried installing in Shepherd and got I'm using |
Yeah. I don't really know how to handle browser ESM, current solutions for that are |
@atomiks it seems like the |
The |
@atomiks hmm, well we are using rollup ourselves to build Shepherd, so how would we get this to work as part of our build? |
Ah I see. So Rollup breaks when bundling it? I would've assumed since it's Node-based it would just work 😖 You could use |
@atomiks yeah, I use Perhaps we could add a check, in the tippy code, and if |
FWIW using rollup-plugin-replace also works, which I tried here shipshapecode/shepherd#420 but I think having a sane default to |
Not sure what you mean here, how would it work? |
@atomiks somewhere before this: if (process.env.NODE_ENV !== "production") { We could do something like:
Not sure exactly, but something like that. I'm not even really sure where these checks are in the code, but if we guard against |
Hmm would like to avoid environment polyfills like that as it adds a side effect that could cause problems for the consumer somehow, I think the replace plugin thing is fine for bundling it as a dependency, better keep the error explicit |
@atomiks I suppose I am just confused then. Under what circumstances is |
It looks like using this allows using globals like I was also reading if you explicitly define |
Tools like Then your minifier (e.g. Terser) will use dead code elimination to remove those whole blocks in production so they can be used in the browser without the error. Haven't tried Rollup itself, but this is more for apps instead of libraries. Libraries already do it the way I'm doing it. It's expected you'll set up your bundler to make this work: https://unpkg.com/react-window@1.8.4/dist/index.esm.js Edit: It seems you're referring to the error occurring inside the browser itself, rather than when Rollup bundles the files for publishing on npm? https://github.com/shipshapecode/shepherd/blob/master/rollup.config.js#L71 In Parcel I just put a tippyjs/demo/addons/index.html Line 9 in 536ad2f
And that's only because of the |
So if you are not setting
While rollup is typically for libraries and webpack more for apps, won't you hit this error in webpack as well, if you didn't define
The rollup build succeeds, but it does not strip out the
It is not though. |
Not necessarily - just if your bundler isn't replacing
You'd need DefinePlugin I believe (haven't tested w/ webpack except for CRA). I think it's a safe assumption that the user needs to set this up as it's an important part of the dev experience these days.
Yeap that's where
Parcel doesn't error out because it replaces the expression for you. It boils down to:
Check the |
Oh and the reason we can't do this is because it doesn't work with ESM, only CJS format. React doesn't provide ESM at all atm probably for that reason Let's say the user somehow wants to use ESM and can't use any tools to fix, or even polyfill, the import tippy from 'tippy.js/esm/tippy.bundle.min.js' I don't even know how they're using that without a proper bundler setup tho. And the reason I removed the minified versions for ESM/CJS is cuz they add tons of files and therefore |
I suppose this just isn't really making sense to me.
Seems very opinionated and I'm not sure why we need to assume this. There are tons of potential situations where you'll use a modern JS import, like you do in all JS development these days, rather than manual IMHO we should be defaulting to assuming we are running in the browser. How often do we need tooltips in a node environment? At the very least we should ship all the formats bundled for both node and browser, rather than defaulting to node. I consider this issue a major breaking change, as anyone using the |
I think I am still confused why built output contains |
All the checks in the build output could be fixed by simply doing |
I think there's a lot of confusion here 😓
The entire point is for development warnings to help you when developing. node_modules/tippy.js/esm/tippy.bundle.js: export default function tippy(targets) {
if (process.env.NODE_ENV !== 'production') {
// contrived, just pretend it's real
if (typeof targets !== 'string') {
console.warn('Woops you did something wrong. Here\'s a fix...');
}
}
return targets;
} your-app.js: import tippy from 'tippy.js'
tippy(1000);
// You get a warning in DEV mode. Now when building for prod and setting NODE_ENV=production, webpack/Parcel does something like this: export default function tippy(targets) {
if ('production' !== 'production') {
// contrived, just pretend it's real
if (typeof targets !== 'string') {
console.warn('Woops you did something wrong. Here\'s a fix...');
}
}
return targets;
} Then your minifier (e.g. Terser) which runs as the next step in your plugins sees that the whole block can be deleted because it's dead code (the block evaluates to function t(x){return x} All that bloat is gone. Leaving the
That would cause a ReferenceError (and break the dead code elimination because it can't be statically analyzed properly anymore) |
@atomiks sure, I understand. We need to heavily document how to set I've tried using rollup-plugin-replace, as suggested here rollup/rollup#487 (comment) This works, but doesn't work correctly. No matter what I pass to this, it removes all the |
@atomiks okay, I fixed the replace 🎉 shipshapecode/shepherd#420 We should document how to do this in webpack, rollup, and other build tools that do not do it automatically like parcel does. |
Yep I agree the documentation will be important. I think there are 3 main bundlers:
We can provide info for these on how to make it work. I think Browserify is dead and Browser ESM doesn't work properly with external deps like |
@atomiks sounds good to me! Thanks for bearing with me through figuring this out. I was pretty ignorant to the whole process 😬 |
@atomiks was there something setting |
@rwwagner90 yes it was removed since it makes HTML content centered. Trying to keep the CSS minimal. |
Perhaps we should call out the style changes, so people can make sure anything they relied upon is updated? |
I added it to the Migration Guide |
@atomiks is everything in the v5 alpha pretty stable? If no APIs should change any further, I would like to go ahead and use the alpha for a new Shepherd release. |
Some more stuff removed and bugs fixed in v5 branch that haven't been released. Maybe wait till beta |
@atomiks okay sure thing. Still looking at July 20th? |
For final release? Yeah. Beta in the next day or so maybe? Doesn't seem like too many people are going to test it out anyway so w/e lol. I'll just do what I think is best as possible. |
Sounds good! Looking forward to the beta 😃 |
@atomiks would you be interested in me creating an Ember wrapper for tippy? |
@rwwagner90 sure! Would be best if we could also publish it under @tippy.js/ember. There is an open issue about it various framework wrappers now. Anyway I'm gonna close this issue because I reminded myself of this tweet https://twitter.com/acemarke/status/1116524847771705345 |
@atomiks I'll work on creating something for Ember sometime soon. I'll let you know. |
Hi everyone,
The next version of Tippy.js is coming in August. In order to ensure it's as stable as possible, I need you to help test it out.
Poll
How are you using the tippy.js package? Answer here if you get time! #550
Goals
Highlights
touch: ["hold", delay]
prop (for long press behavior)arrow: string | Element
values to use your own shapecreateSingleton
method, supersedesgroup()
Installation
Package Managers:
CDN:
Changes
View all of the details in the PR in progress.
Migration Guide
View guide
The warnings will help a lot with this.
Note to CDN users, it's recommended to migrate using the development file:
If you were specifying a custom file path import
Check the new folder structure and filenames.
umd
is nowcjs
(Node) oriife
(browser).If you want the material filling effect back (it's no longer default)
Node:
Browser:
If you were using
arrowType: 'round'
Include the
svg-arrow
CSS, and use thearrow
prop instead.Node:
Browser:
If you were using
followCursor
Enhance the
tippy
base function with this prop by importing it fromtippy.js/extra-props
.Node:
Browser:
If you were using
tippy.group()
Use
createSingleton()
and import fromtippy.js/addons
.Node:
Browser:
If you were using the
target
optionUse
delegate()
and import fromtippy.js/addons
.Node:
Browser:
If you were using the
showOnInit
optionIt's now named
showOnCreate
, to match theonCreate
lifecycle hookIf you were using the
size
optionIt's been removed, as it's more flexible to just use a theme and specify the
font-size
andpadding
properties.If you were using the included themes
google
is nowmaterial
If you were creating custom themes
[x-placement]
attribute is now[data-placement]
.tippy-roundarrow
is now.tippy-svg-arrow
.tippy-tooltip
no longer haspadding
on it, rather the.tippy-content
selector does..tippy-tooltip
no longer hastext-align: center
If you were using default animations or creating custom animations
shift-away
,shift-toward
,scale
andperspective
need to be imported separately now.Node:
Browser:
visible
state has no translation (of 0px, instead of 10px like before).If you were using virtual reference elements
Pass a placeholder element in instead of a plain object:
You can overwrite its
getBoundingClientRect
method, just like a regular object. Make sure this placeholder element does not get appended to the document though.If you were calling
instance.set()
/tippy.setDefaults()
/ accessingtippy.defaults
Types
Props
is notPartial
anymore, it'sRequired
Options
removed (usePartial<Props>
)BasicPlacement
renamed toBasePlacement
The text was updated successfully, but these errors were encountered: