sveltejs / sveltejs/kit

"svelte-package" --tsconfig option ignores everything but compilerOptions

Open
#12,257 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:svelte-package
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

The "svelte-package" bin has the option --tsconfig, but it ignores all options except compilerOptions. This means "include", "exclude" options that you set in the tsconfig/jsconfig are not respected.

The issue is probably stemming from these lines:
https://github.com/sveltejs/kit/blob/cf99ac884986576506b6080e6d7e9fc530f9e62a/packages/package/src/typescript.js#L69-L82

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-mnsqql?file=jsconfig.json

If you run "npm run package" it runs "svelte-package -o package build". You will see that there are "Image.svelte", "Image.svelte.d.ts", "Image.stories.svelte" and "Image.stories.svelte.d.ts" files generated in the package folder.
If you uncomment the "exclude" block in the jsconfig.json file and run it again you will see that it still includes the "Images.stories.svelte" file but it does not generate a ".d.ts" file for it.

If you run "npm run package2" it runs "svelte-package --tsconfig=jsconfig.build.json -o package build". So it uses another version of jsconfig which extends the normal jsconfig and adds the exclude option. You will see that it still generates the ".d.ts" files for both svelte files which means the options are ignored.

Logs

No response

System Info
System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.2.1 
    @sveltejs/kit: ^2.0.0 => 2.5.10 
    @sveltejs/package: ^2.3.1 => 2.3.1 
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.1.0 
    svelte: ^4.2.7 => 4.2.17 
    vite: ^5.0.3 => 5.2.11
Severity

annoyance

Additional Information

Right now we are adding the ".stories.svelte.d.ts" which works to not include the files, but it would be good to just not build them in the first place. A general "ignore" or "exclude" option for "svelte-package" to not even generate the ".stories.svelte" files would be even better.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/package/src/typescript.js lines 69-82 and reproduce the issue with the linked StackBlitz project using npm run package and npm run package2. Check how jsconfig.json and jsconfig.build.json options are loaded; done means include and exclude are respected and excluded story files are not generated.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.