Part dependencies
Dependencies in a part's configuration object are controlled by the from
and after
properties.
In both cases, you should specify the actual configuration object of the dependency part, not merely a string with its name.
Dependencies configured on parts do not need to be included in the parts
property
passed to the Design constructor. 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:
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.
If you only have one part for the after
property, you do not have to specify an array:
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.
import { exampleBack } from './back.mjs'
const part = {
name: 'example.front',
from: exampleBack,
draft: ({ part }) => part
}
Unlike after
, from
only ever takes one part since you can only extend one part.