Skip to content
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

const { js, css } = svelte.compile(...) #795

Closed
Rich-Harris opened this issue Aug 29, 2017 · 1 comment
Closed

const { js, css } = svelte.compile(...) #795

Rich-Harris opened this issue Aug 29, 2017 · 1 comment

Comments

@Rich-Harris
Copy link
Member

This is a relatively minor aesthetic thing, but the current API doesn't treat CSS as a first-class citizen. Rather than this...

const { code, map, css, cssMap, ast } = svelte.compile(...);

...I think we should have this:

const { js, css, ast } = svelte.compile(...);

console.log(js.code); // string
console.log(js.map);  // object with toString method

console.log(css.code); // string
console.log(css.map);  // object with toString method

This can be done as a non-breaking change with a deprecation warning (until v2, when we'd switch over to the new API) by returning an object on which code, map and cssMap were getters that printed the warning, and by adding a toString method on css that also printed the warning.

@Rich-Harris
Copy link
Member Author

Then again v2 will change the return value to a Promise, so perhaps it makes sense to wait until then.

@Rich-Harris Rich-Harris added this to the 2.x milestone Sep 1, 2017
@Rich-Harris Rich-Harris mentioned this issue Mar 18, 2018
Rich-Harris added a commit that referenced this issue Apr 1, 2018
output { js, css, ast } from svelte.compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant