-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Standalone vs non-standalone #9
Comments
It would be nice to have a mode that outputs just the generated code for dom manipulation (create, update, teardown), so the user can choose whatever state management library they would like (eg. mobx) Not sure how that would best interact with nested components though. |
Looking at progressive enhancement, I think it would be particularly useful to have a little bit of library code that could handle walking through the existing DOM to find a valid target and get it into the correct state. |
I've been thinking it'd be good if the compiler had an The same could apply to methods that don't differ between components, e.g. Basically, what Babel does – marking which helpers are used then either injecting them or importing them depending on the |
Implemented as of 1.5.0 – build tool integrations will need to be updated to take advantage of it though |
It looks like the built |
Good catch, thanks – will add the fix to #219 |
hmm, in my freshly-installed Svelte 1.6.0, I see a |
Is there any technical reason why cjs modules couldn't be supported as well? Wouldn't `const { ${names.join( ', ' )} } = require('svelte/shared-cjs.js')` work as well as `import { ${names.join( ', ' )} } from 'svelte/shared.js'` ? |
Hm. Producing a As for your other issue, 1.6.0 is working fine for me with this. My |
that's weird... it should be there, starting at line 6967 of https://unpkg.com/[email protected]/compiler/svelte.js. That not the case for your installation?
Not really, though if we were doing cjs then we should probably do all the others, and that means treating them the same as other dependencies i.e. passing them in to the And Svelte generates ES5, so couldn't use destructuring – would have to have a temporary variable and do And we'd need to have CJS and AMD and script tag builds of the shared helpers (or a UMD build). So I looked at all those considerations and thought 'it's not worth the extra complexity' – since the only people who would be using shared helpers are using bundlers, and if your bundler doesn't natively support ES modules at the end of 2016 then it's probably time to find another bundler 😀 |
CJS modulesFair enough. It's true, I can add 1.6.0 published correctlybaaaaaah I see what was going on. I'd been reading the new code in #215 and was looking for references to "standalone" in the output code. I see now that it changed from "standalone" to "shared" in #219. |
Having zero runtime dependencies is really nice – it makes the generated code easier to follow and more versatile. Optionally, though, it might be good to offer builds that reduce code duplication – for example, the
observe
code is the same everywhere, and there are a few DOM helpers that could live externally.The text was updated successfully, but these errors were encountered: