1
0
Fork 0
freesewing/sites/dev/docs/reference/api/part/config/dependencies
Joost De Cock ab3204f9f1 chore: Port FreeSewing.dev to docusaurus
The replaces the NextJS site powering FreeSewing.dev with a Docusaurus
setup. It's part of my efforts to simplify FreeSewing's setup so we can
focus on our core value proposition.
2024-09-28 13:13:48 +02:00
..
readme.mdx chore: Port FreeSewing.dev to docusaurus 2024-09-28 13:13:48 +02:00

---
title: Part dependencies
---

Dependencies in a part's configuration object are controlled by the `from` and `after` properties.

:::note

In both cases, you should specify the actual configuration object  of the dependency part,
not merely a string with its name.

:::

:::tip

Dependencies configured on parts do not need to be included in the `parts` property
passed to [the Design constructor](/reference/api/design). FreeSewing core will 
recursively resolve all dependencies and add them to the design for you.

:::

## after

The `after` property holds an array of parts that should be drafted before the current part:

```js
import { exampleBack } from './back.mjs'
import { exampleFront } from './front.mjs'

const part = {
  name: 'example.sleeve',
  after: [ exampleBack, exampleFront ],
  draft: ({ part }) => part
}
```

The effect of the `after` property is that drafting of this part will be deferred until all the parts listed 
in the `after` property are drafted.

:::tip

If you only have one part for the `after` property, you do not have to specify an array:

```js
import { exampleBack } from './back.mjs'

const part = {
  name: 'example.front',
  after: exampleBack,
  draft: ({ part }) => part
}
```

:::

## from

The `from` property holds a part that should be used as the base for the current part.
In other words, the current part will _extend_ the part listed in `front` and inherit all its content.

```js
import { exampleBack } from './back.mjs'

const part = {
  name: 'example.front',
  from: exampleBack,
  draft: ({ part }) => part
}
```

:::warning

Unlike `after`, `from` only ever takes one part since you can only extend one part.

:::