Describe the bug
When using TypeScript and setting the tsconfig setting importHelpers to true, TypeScript will not inline transpilation helpers and instead import them from tslib. Since the instance and module script are transpiled independently, these imports may get duplicated which results in a "X was already declared" error.
<script lang="ts" context="module">
export async function foo() {}
</script>
<script lang="ts" context="module">
export async function bar() {}
</script>
Expected behavior
Imports are deduplicated somehow. Since this is a special case I think it's okay to have special code for it. For example doing a regex for check for tslib imports, store them somewhere and filter out duplicated imports in the next transformation.
Information about your project:
Your browser and the version: irrelevant
Your operating system: irrelevant
svelte-preprocess version 4.7.3
Whether your project uses Webpack or Rollup: Rollup/Vite
IMO, there should not be awaiter for es2019 target.
In fact, svelte-preprocess hardcodes ts target to es6, but even in this case ts should output plain async/await without tslib generator hacks
Describe the bug When using TypeScript and setting the tsconfig setting
importHelpers
totrue
, TypeScript will not inline transpilation helpers and instead import them fromtslib
. Since the instance and module script are transpiled independently, these imports may get duplicated which results in a "X was already declared" error.This came up in https://github.com/sveltejs/kit/issues/1577
To Reproduce tsconfig:
Svelte file:
Expected behavior Imports are deduplicated somehow. Since this is a special case I think it's okay to have special code for it. For example doing a regex for check for tslib imports, store them somewhere and filter out duplicated imports in the next transformation.
Information about your project:
Your browser and the version: irrelevant
Your operating system: irrelevant
svelte-preprocess
version 4.7.3Whether your project uses Webpack or Rollup: Rollup/Vite