Skip to content

Commit

Permalink
[feat] use preserveValueImports flag in create-svelte (#3064)
Browse files Browse the repository at this point in the history
TypeScript doesn't know about import usages in the template because it only sees the script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher, therefore also bump the version of TS and Prettier (the latter in order to deal with the new TS syntax).
Turning on preserveValueImports turns off the advanced but somewhat brittle import transpilation in svelte-preprocess which should give a small performance boost and more robustness.
  • Loading branch information
dummdidumm committed Feb 11, 2022
1 parent a780bf6 commit d788cf2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-ears-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

use preserveValueImports flag
4 changes: 2 additions & 2 deletions packages/create-svelte/shared/+prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"devDependencies": {
"prettier": "^2.4.1",
"prettier-plugin-svelte": "^2.4.0"
"prettier": "^2.5.1",
"prettier-plugin-svelte": "^2.5.0"
}
}
4 changes: 2 additions & 2 deletions packages/create-svelte/shared/+typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"typescript": "^4.4.3",
"typescript": "~4.5.4",
"tslib": "^2.3.1",
"svelte-check": "^2.2.6",
"svelte-preprocess": "^4.9.4"
"svelte-preprocess": "^4.10.1"
}
}
9 changes: 7 additions & 2 deletions packages/create-svelte/shared/+typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
/**
svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
to enforce using \`import type\` instead of \`import\` for Types.
*/
*/
"importsNotUsedAsValues": "error",
/**
TypeScript doesn't know about import usages in the template because it only sees the
script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
*/
"preserveValueImports": true,
"isolatedModules": true,
"resolveJsonModule": true,
/**
To have warnings/errors of the Svelte compiler at the correct position,
enable source maps by default.
*/
*/
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
Expand Down

0 comments on commit d788cf2

Please sign in to comment.