-
Notifications
You must be signed in to change notification settings - Fork 33
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
fix: $destroy and createRoot are no more #328
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ping me once this is in and I'll rebase #325 accordingly
I will! I'm still figuring out how to deal with |
I added the
Either path feels like a bit of a bummer! |
Yup, that's what I think as well. I'm trying to change the rerender test to use that ^^^ pattern, but for some reason it doesn't react to
I think we just need to change the name of the test file to be Right now my battle plan is
So yeah, weeeeee, supporting several major versions is fun, fun, fun. 🤪
|
202aefe
to
06ba816
Compare
For now I've resorted to use the legacy API, as the use of runes don't seem to work in the test environment (which, mind you, could be a problem on this side of the keyboard) and the important part is to have the package work with Svelte 5.
06ba816
to
44b20b4
Compare
46c2e22
to
2b1449b
Compare
2b1449b
to
6f494ad
Compare
@mcous This is not the patch we deserve, but probably the patch we need. I'm using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes because this breaks type exports in package.json
for the existing library.
Additionally, the separate entry points for v4 vs v5 seems a little unnecessary from a technical standpoint, because the public APIs remain unchanged. What's the value of it this approach over what's currently in #325, where pure.js
continues to support both?
@@ -4,10 +4,8 @@ | |||
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.", | |||
"main": "src/index.js", | |||
"exports": { | |||
".": { | |||
"types": "./types/index.d.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, we need to make sure we don't drop this types
export, or it'll break TS using more modern moduleResolution
modes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the types
key right below the exports take care of that, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, no. If TS sees "exports"
in moduleResolute: nodenext
or bundler
and there's no exports[].types
it'll get sad
See #228
package.json
Outdated
"default": "./src/index.js" | ||
}, | ||
".": "./src/index.js", | ||
"./svelte5": "./src/svelte5-index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a corresponding types
esport for Svelte 5?
src/__tests__/context.test.js
Outdated
|
||
import { render } from '..' | ||
import Comp from './fixtures/Context.svelte' | ||
|
||
test('can set a context', () => { | ||
const message = 'Got it' | ||
test.skipIf(SVELTE_VERSION >= '5' && process.env.VITEST_ENV == 'happy-dom')( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In another test I used the user-agent to test for jsdom vs happy-dom. It's ever-so-slightly janky, but I like it because it doesn't require adding more environment variables / setup. Using an environment variable makes it harder to use vitest
directly, which I do with some frequency to noodle on stuff
Related, should we have a little __tests__/environment.ts
helper file that exports IS_SVELTE_5
, IS_HAPPY_DOM
, IS_JSDOM
, etc. to make these a little less repetitive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have a little tests/environment.ts helper file that exports IS_SVELTE_5, IS_HAPPY_DOM, IS_JSDOM, etc. to make these a little less repetitive?
Yeah, that would make a lot of sense.
src/pure.js
Outdated
if (IS_SVELTE_5) | ||
console.warn('for Svelte 5, use `@testing-library/svelte/svelte5`') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I'm open to the separate entry points approach! That being said, I don't see anything in this PR that really justifies it. Is it a future-proofing thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the previous comment, it's to deal with import from 'svelte/legacy'
. We could probably dig out darker magic to do it another way, but I do feel there will be other things in Svelte 5 that will be easier if we just have different files implementing the same(ish) interface rather than having a file that tries to satisfy all versions at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh, yeah duh, my bad, that makes total sense.
Aside: this makes me think dropping 3.0 in the next
branch (in a separate PR to be responsible about it) will make things easier.
I'm not totally sure what to do about collecting multiple breaking changes without a prerelease version. Maybe we should switch over to an beta
branch for breaking changes? Or consider switching next
to be a prerelease in semantic-release
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside: this makes me think dropping 3.0 in the next branch (in a separate PR to be responsible about it) will make things easier.
What would we cut off?
@@ -0,0 +1,145 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a lot of duplication for little payoff. If you want to have separate entry points, would it be better to re-export pure.js
's exports and only override the public methods that changed?
Alternatively, can we move the split to an internal facade instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My development steps are
- Make it
- Make it work
- Make it pretty
This PR is at stage (2). all the functions that aren't different in svelte5.js
should really be imported from pure.js
. But first I was interested to see how deep the hole had to be. And then backfill and tidy up the garden again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, happy to defer to whatever approach you want to take. Just wanted to point out opportunities nip stuff in the bud LoC-wise
|
🎉 This PR is included in version 4.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.