evanw / evanw/esbuild

Question: splitting component logic from library code

Open
#3,955 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Maybe not the best place for a library-related question but I can't find something like a Discord server. Sorry for that.

I'm looking for a way to split component based logic from the base library/framework where the components is written in. So think of a **Button** and a **Dropdown** Component both written in `Svelte`. I try to find out a way to bundle and compile the code in to something like:
```
/build:
- svelte.js (base svelte code. Not related to the logic of Button.svelte but necassary to make the component work.
- button.js (compiled svelte code related to the button.svelte component. Needs svelte.js to be loaded to work)
- dropdown.js (compiled svelte code related to the dropdown.svelte component. Needs svelte.js to be loaded to work)
```

My knowledge about code bundlers is a little bit limited so reading the [docs of esbuild](https://esbuild.github.io/) is sometimes hard.

**Question**: how to compile svelte components such that the base svelte code gets splitted of the specific component logic?

Thanks in advance!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the esbuild documentation linked in the issue and the requested /build outputs. Establish whether the desired Svelte component and shared-runtime split is supported, then document a reproducible configuration or clearly state the limitation and expected alternative.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.