sveltejs / sveltejs/kit

`svelte-package` warn about circular dependencies

Open
#9,928 1 comment 1 reaction 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 problem

svelte-package has a bunch of very useful built-in health checks like

@sveltejs/package found the following issues while packaging your library:
You have a svelte field in your package.json, but no root export in your exports. Please align them so that bundlers will resolve consistently to the same file.

Would be great if it could also check for circular dependencies within the /lib folder.

Describe the proposed solution

With this setup, svelte-package should warn about circular dependency between Component and index.

// src/lib/index.ts
export { default as Component, default } from './Component.svelte'

const variable = 42
<script>
  // src/lib/Component.svelte
  import { variable } from './'
</script>

{variable}
Alternatives considered

No response

Importance

would make my life easier

Additional Information

This would prevent problems like https://github.com/janosh/svelte-multiselect/issues/228 causing packages to break in the REPL and triggering NPM warnings.

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 by locating the existing health checks used by svelte-package, then review the example files src/lib/index.ts and src/lib/Component.svelte to understand the reported cycle. Done means packaging this setup emits a circular-dependency warning for the /lib folder, with coverage for the example case.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.