thheller / thheller/shadow-cljs

feature request: allow matching multiple targets in key of target-defaults map

Open
#799 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
2.4k
Forks
192
Avg merge
3h 11m
Merged PRs (30d)
1

Description

Currently target-defaults lets you reuse configurations for the same build target, e.g. :browser, but it does not let you reuse configurations for separate yet related build targets, e.g. :browser and :browser-test.

As a solution for this, would you consider a PR that allowed :target-defaults to match keywords in a set (or any collection)?

My use-case is sharing :js-options across related browser build targets:

 :target-defaults
 {:browser
  {:js-options
   {:extensions [".web.js" ".js" ".json"]
    :resolve {"react-native" {:target :npm
                     :require "react-native-web"}}}}
  :browser-test
  {:js-options
   {:extensions [".web.js" ".js" ".json"]
    :resolve {"react-native" {:target :npm
                              :require "react-native-web"}}}}}}

If :target-defaults matched build target configurations for sets, then the above could be:

 :target-defaults
 {#{:browser :browser-test}
  {:js-options
   {:extensions [".web.js" ".js" ".json"]
    :resolve {"react-native" {:target :npm
                     :require "react-native-web"}}}}

One consideration is ordering of merges if multiple :target-default are matched. Below ~8 items maps are an array-map, but still since Clojure maps don't guarantee order, this could give false assumptions if somehow someone's config unexpectedly got too big.

What do you think? Have you considered allowing multiple targets in a :target-default entry? Do you have other ideas for how to address shared configs for related build targets?

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

No implementation files or tests are named. Start by locating the target-defaults handling and its existing tests, then trace how target keys are matched and configurations are merged. Done means defining multiple-target matching and deterministic merge behavior, with tests covering shared targets and overlapping matches.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.