-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[WIP] Implement reactive assignments #1839
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
Conversation
<script> | ||
export default { | ||
onrender () { |
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.
I stared at this for a while going "wtf is onrender
". It wasn't until I went and did a search that I realized it's deprecated syntax.
Glad this is getting updated, feels weird that the tests were using it 🤔
Ok, the tests are done-ish — I clumsily squashed and force-pushed the couple dozen or so individual commits. (Some of them no longer really make sense, some will need to be renamed, some test things that we need to find alternatives for, like transition events.) A lot of the test JavaScript (as opposed to the components) will no longer work, since it uses |
@@ -2,18 +2,16 @@ | |||
"name": "svelte", | |||
"version": "2.15.1", | |||
"description": "The magical disappearing UI framework", | |||
"main": "compiler/svelte.js", | |||
"main": "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.
Should index.js
(the lifecycle etc hooks functions) be pkg.module
rather than pkg.main
? They're not in commonjs, nor do I think they should be.
That would leave the question of 'well what should pkg.main
be?' I don't know. Maybe nothing?
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.
Good question. Maybe nothing? Or maybe we capitulate to Node and have
"main": "index.js",
"module": "index.mjs"
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.
How about pkg.main
points to a file that just throws a big old exception and lets the user know what and how they should be importing instead? (Hopefully there aren't any current bundlers that will use pkg.main
when pkg.module
is available.) The message could say 'lifecycle stuff lives here, the compiler lives here, animation stuff lives here, observable stuff lives here' etc
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.
I've adopted putting "main": "index"
(without the extension) — as far as I know, according to the current Node modules draft, it will choose the appropriate extension depending on whether it is imported or required.
Is there a real reason to keep the |
I did wonder about that. I think there probably are cases where it's still useful. For example in Sapper a layout component needs to do this... <svelte:component this={child.component} {...child.props}/> ...so to achieve the same thing we'd need to do one of these: <!-- lowercased name implies DOM node, and member expressions
aren't currently supported -->
<child.component {...child.props}/> <script>
export let child;
let Component;
$: Component = child.component;
</script>
<Component {...props}/> (Aside: it suddenly occurs to me that layout components will need to explicitly declare the There's also a cost to assuming that a component's constructor could change — Svelte needs to generate more code for <!-- a virtual scroll component, maybe -->
<script>
export let items;
export let Row;
</script>
{#each items.slice(start, end) as item}
<Row {...item}/>
{/each} <script>
export let items;
export let Row;
</script>
{#each items.slice(start, end) as item}
<svelte:component this={Row} {...item}/>
{/each} So maybe the way to look at this is that it doesn't break the guideline as they're two separate problems — if you want a component to be changeable, use |
I'm still using But, in the event of See here for example |
Co-Authored-By: Rich-Harris <[email protected]>
Co-Authored-By: Rich-Harris <[email protected]>
This is gonna take a while. First order of business is updating all the tests. I'm going to see how far I can get doing it via svelte-upgrade: sveltejs/svelte-upgrade#12
Assignment instrumentation:
$$make_dirty
called outside of the boolean operation: