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

Support for array of preprocessors #279

Closed
itsMapleLeaf opened this issue Jul 4, 2020 · 6 comments
Closed

Support for array of preprocessors #279

itsMapleLeaf opened this issue Jul 4, 2020 · 6 comments
Assignees
Labels
documentation Improvements or additions to documentation feature request New feature or request Fixed Fixed in master branch. Pending production release.

Comments

@itsMapleLeaf
Copy link
Contributor

Describe the bug
import type syntax causes a type error. This is needed for ESM-sensitive bundlers that need to differentiate types from values for erasure during compilation

To Reproduce
Steps to reproduce the behavior:

// svelte.config.js
const preprocess = require("svelte-preprocess")

module.exports = {
	preprocess: [
		preprocess.postcss(),
		preprocess.typescript({ transpileOnly: true }),
	],
}
// types.ts
export type Secret = string
<!-- Component.svelte -->
<script lang="ts">
  import type { Secret } from './types' // type error on this line
  const secret: Secret = '42'
</script>

For example a code snippet that is treated in a way you don't expect.

Expected behavior
Type imports should be parsed without errors

Screenshots
If applicable, add screenshots to help explain your problem.
image

System (please complete the following information):

  • OS: Windows 10
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode
@itsMapleLeaf itsMapleLeaf added the bug Something isn't working label Jul 4, 2020
@dummdidumm
Copy link
Member

I think it's because you use an array of preprocessors, that is not supported yet.
If you refactor your svelte.config.js to

const preprocess = require("svelte-preprocess")

module.exports = {
	preprocess: preprocess({
                postcss: true,
		typescript: { transpileOnly: true }
        }),
}

does it work then?

@itsMapleLeaf
Copy link
Contributor Author

That indeed fixes it, thanks 😅 maybe a note in the docs would be helpful?

@dummdidumm
Copy link
Member

Absolutely

itsMapleLeaf added a commit to itsMapleLeaf/language-tools that referenced this issue Jul 5, 2020
Adding an array causes the extension to work improperly (sveltejs#279), so this note should save some confusion
dummdidumm pushed a commit that referenced this issue Jul 6, 2020
Adding an array causes the extension to work improperly (#279), so this note should save some confusion
@dummdidumm dummdidumm added the documentation Improvements or additions to documentation label Jul 6, 2020
@dummdidumm dummdidumm changed the title Syntax error on import type Support for array of preprocessors Jul 6, 2020
@dummdidumm dummdidumm added feature request New feature or request and removed bug Something isn't working labels Jul 6, 2020
@kevmodrome
Copy link

What would be needed for this to be supported? Willing to help any way I can! Not having this feature makes it impossible to use MDSveX and sass together, for example

@dummdidumm
Copy link
Member

I think @kaisermann wanted to take a shot at this, not sure what his status on that is though.

@kaisermann
Copy link
Member

@dummdidumm I've stopped what I was doing a while ago, but will probably get back to it tomorrow or this weekend!

@kaisermann kaisermann self-assigned this Jul 23, 2020
dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Jul 30, 2020
dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Jul 30, 2020
dummdidumm added a commit that referenced this issue Jul 30, 2020
* (feat) Support for multiple preprocessors

#279

Co-authored-by: Christian Kaisermann <[email protected]>
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature request New feature or request Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants