Skip to content

Fabrication presets and variants ​

Fab presets, custom presets with bindPCB and one design for several fabs with variants. Advanced. Every file of the fab set is in fab-set.md; stackup and rule values in stackup.md and rules.md; sourcing tags in sourcing.md.

tsx
import PCB from '@pcbjs/fab/JLCPCB/2-Layer'

export default <PCB name="Blinky" rev="A" color="Black" silk="White" finish="ENIG">{/* … */}</PCB>

Presets ​

A <PCB> with the fab's stackup, rules and sourcing tags, plus three props:

PropTakes
colormask colour: a name of the fab's palette, "Matte Green", or any CSS colour; a name matches whatever its case, spaces, _ or -
silklegend colour, the same way
finish'HASL', 'LeadFreeHASL', 'ENIG', 'ImmersionSilver', 'ImmersionTin', 'OSP', 'HardGold'
  • Order: base, project defaults, preset, element props. The rules of defineDefaultBoard never change a preset's, rules={{ clearance: 0.2 }} merges over them, an explicit stackup replaces the preset's.
  • JLCPCB minHoleToHole: { pad: 0.45, via: 0.2 }: the router keeps 0.45 between its vias, DRC lets hand-placed vias closer.
  • JLCPCB at 1 oz: maskWeb: 0.1, maskWebByColor: { Black: 0.13, White: 0.13 }, picked by the mask colour of <PCB> or the target; README-fab prints mask web 0.13, black mask. A board maskWeb overrides it, 0.20 for 2 oz; other presets leave the rule out.

Modules are @pcbjs/fab/<Fab>/<n>-Layer:

FabRulesModules: stackup, finishMask colours
JLCPCBJLCPCB2-Layer: JLCPCB_2L, HASL; 4-Layer: JLCPCB_4L_7628, HASL; 4-Layer-3313: JLCPCB_4L_3313, thin prepreg for fine-pitch impedance, HASL; 6-Layer: sixLayer, ENIG; 8-Layer: eightLayer, ENIG; all greengreen, red, yellow, blue, white, black, purple
PCBWayPCBWAY2-Layer: twoLayer; 4-Layer: fourLayer; HASL, greenthe JLCPCB set, matte black, matte green
OSHParkOSHPARK2-Layer: OSHPARK_2L; 4-Layer: OSHPARK_4L; ENIG, purplepurple
EurocircuitsEUROCIRCUITS2-Layer: twoLayer; 4-Layer: fourLayer; lead-free HASL, greengreen, red, blue, white, black
AdvancedPCBADVANCEDPCB2-Layer: twoLayer; 4-Layer: fourLayer; ENIG, blackgreen, red, blue, white, black

PCB.preset holds the preset's name, stackup, rules, colors, silkColors, finishes and sourcing, frozen; @pcbjs/fab exports FABS, every preset path.

Your own preset ​

tsx
import { bindPCB } from '@pcbjs/fab'
import { BASE, mergeRules } from '@pcbjs/lib/rules'
import { fourLayer } from '@pcbjs/lib/stackups'

const PCB = bindPCB({
  name: 'Local 4-Layer', fab: 'Local',
  stackup: fourLayer({ finish: 'ENIG', maskColor: 'Blue' }),
  rules: mergeRules(BASE, { clearance: 0.2, minTrackWidth: 0.2 }),
  colors: { Blue: '#173a7a', Black: '#1a1a1a' },
})

export default <PCB name="Probe" rev="0.1.0" color="black">{/* … */}</PCB>

Also silkColors, finishes, sourcing, autoroute, cpl and fabNotes. bindPCB({ ...PCB.preset, name: 'House 2-Layer' }) copies a preset; isBoundPCB(fn) tells a bound component from a plain one.

Variants ​

tsx
import { variants } from '@pcbjs/core'
import { twoLayer } from '@pcbjs/lib/stackups'
import JLCPCB from '@pcbjs/fab/JLCPCB/2-Layer'
import OSHPark from '@pcbjs/fab/OSHPark/2-Layer'

const House = { name: 'House', board: { stackup: twoLayer({ thickness: 1.2 }) }, rules: { clearance: 0.2 }, color: 'Black', sourcing: ['US'] }
const PCB = variants(JLCPCB, OSHPark, House)

export default <PCB name="Multi" rev="A">{/* … */}</PCB>

One compile per target, each with its own DRC, fab set and viewer entry. A target is a preset, the plain PCB of @pcbjs/core named Base, or an object:

KeyTakes
name, fabstrings; unnamed is Target N; a repeated name or slug throws
boarda partial <PCB> spec without rules, fabNotes and fonts, such as { stackup } or { place: { seed: 2 } }; the element's own props win
rules, color, silk, finish, sourcing, fabNotesas on a preset
routeSeparatelytrue routes this target on its own
  • The element's rules, color, silk and finish apply to every target.
  • Targets with the same copper count, autoroute parameters and auto placements share one routing under the strictest rules, so identical copper.
  • PCB.targets holds the resolved targets; isVariants(fn) tells such a component apart; compileBoards(root) returns one board per target with board.variant = { name, index, names, fab }.
  • Orderable only when every target is. The slug is the name in lower case, each run of other characters a -: osh-park-2-layer.
WhatSingle boardTarget
fab set.pcbjs/fab/Multi/.pcbjs/fab/Multi/<slug>/
fab zipMulti-fab-<rev>.zipMulti-fab-<rev>-<slug>.zip
site databoards/Multi.jsonboards/Multi/<slug>.json
3D, 3d.mdboards/Multi.glbboards/Multi/<slug>.glb
dev board data/__pcbjs/Multi/board.json/__pcbjs/Multi/<slug>/board.json

MIT licensed. A proof of concept, pre 0.1.