Description
Describe the bug
Uninstalled optional peer dependencies such as 'pug' causes the following error during type checking with tsc
error TS2307: Cannot find module 'pug' or its corresponding type declarations.
> import type { Options as PugOptions } from 'pug';
This issue did not occur in svelte-preprocess v5.1.4 because @types/pug was installed as a direct dependency. Since v6, that type dependency has been removed, leading to errors when pug is not installed.
The issue is also applicable for other optional peer dependencies, such as @babel/core
. Which can be remedied by having @types/babel__core
as dependency.
Logs
To Reproduce
- With pnpm, create a typescript project with
esbuild.config.ts
that importssveltePreprocess
. - Make sure that
skipLibCheck
intsconfig.json
is not set tofalse
. - Run
pnpm tsc
Expected behavior
No errors should be thrown when pug is not installed, as it is an optional dependency.
Stacktraces
Information about your project:
-
Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)
-
Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)
-
svelte-preprocess
version: 6.0.3 -
Whether your project uses Webpack or Rollup:
Additional context