tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
485 stars 38 forks source link

Use defaults passed to sveltePreprocess #212

Closed jankalfus closed 3 years ago

jankalfus commented 3 years ago

The official Svelte plugin for VS Code is able to load preprocess options passed to sveltePreprocess in svelte.config.js, and set up defaults correctly. It would be awesome to have support for that in this plugin as well.

For example, if one sets up typescript in svelte.config.js as the default language:

const sveltePreprocess = require("svelte-preprocess");

const preprocessOptions = {
  sourceMap: true,
  defaults: {
    script: "typescript",
  },
};

module.exports = {
  preprocess: sveltePreprocess(preprocessOptions),
};

...then typescript can be used in the script tag without having to specify lang:

<script>
  export let name: string;
</script>

This works nicely in VS Code with the official Svelte plugin: obrazek

But fails in WebStorm with this plugin (0.18.0.203): obrazek

Related issue from the VS Code plugin repository: https://github.com/sveltejs/language-tools/issues/593

tomblachut commented 3 years ago

Yes indeed that would be nice, thanks for raising!

mikerourke commented 3 years ago

@tomblachut I just wanted to chime in here and say you can probably close this issue. Svelte is deprecating the defaults option in svelte-preprocess and recommending you explicitly specify the language in the <script> tag (i.e. <script lang="ts">. Here's the message I'm seeing in my terminal:

[svelte-preprocess] Deprecation notice: using the "defaults" option is no longer recommended and will be removed in the next major version. Instead, define the language being used explicitly via the lang attribute.

By the way, thank you so much for all the great work on this plugin! I don't know what I'd do without it.

tomblachut commented 3 years ago

@mikerourke thanks for the info and for kind words :)

I'll rename this issue to better reflect that it's specifically about "defaults" and close it.