Skip to content

Support separate client and server bundles #751

@flybayer

Description

@flybayer

Current Behavior

Currently tsdx only generates one single bundle.

Desired Behavior

We are using tsdx for Blitz.js and we need separate client and server bundles. The Blitz package has (1) code that is isopmorphic and (2) code that only runs on the server.

Currently we have two separate packages to accomplish this but it's a huge mess for code organization because we can't organize code by feature. Code for a certain feature has to be separated in two separate packages. Instead we want all this code to be in a single package.

And then we want to be able to import a specific bundle, maybe like this:

import stuff from 'pkg/client'
import stuff from 'pkg/server'

Suggested Solution

I'm not sure the best way to do this, but I could image having a file structure like this:

src/client.ts      //re-exports from all client.ts files
src/server.ts      //re-exports from all server.ts files
src/featureA/client.ts
src/featureA/server.ts
src/featureA/shared.ts

Who does this impact? Who is this for?

Anyone writing packages that have different functionality on client vs server.

Describe alternatives you've considered

Custom rollup config which I don't know how to do 😅

Additional context

blitz-js/legacy-framework#928

Metadata

Metadata

Assignees

No one assigned

    Labels

    problem: staleIssue has not been responded to in some timesolution: duplicateThis issue or pull request already existstopic: multi-entryRelated to multi-entry support

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions