@@ -112,6 +112,52 @@ after `--`, for instance you could run `pnpm test -- --concurrency 2`.
112112- ` pnpm start:prod ` : Run production builds and start production mode servers in
113113 parallel.
114114
115+ #### Building a new package
116+
117+ New packages should be configured with a few requirements in mind:
118+
119+ 1 . You need to make sure ` package.json ` scripts are named such that that
120+ turborepo will hook into them at the expected times.
121+
122+ - See [ turbo.json] ( ./turbo.json ) to see the base configuration and ensure you
123+ use script names that match the tasks that turborepo is configured to run.
124+ - You don't need to define scripts for all the tasks that are in the root
125+ ` turbo.json ` config, just define the ones that make sense for your project.
126+ - You shouldn't define scripts for tasks that just trigger other tasks;
127+ instead configure turborepo dependencies to trigger the tasks. This will
128+ allow turborepo to cache and parallelize things more effectively.
129+ - In general, ` build ` , ` fix ` , and ` test ` are the main turborepo task graph
130+ entry points, and any sub-tasks that apply to your package should be
131+ configured as dependencies somewhere in the graph rooted at one of those.
132+ - If you need sub-tasks or a task configuration that only apply to your or a
133+ small few packages, add a package-scoped ` turbo.json ` , see [ the one in the
134+ insights app] ( ./apps/insights/turbo.json ) as an example.
135+
136+ 2 . Make sure to configure the tools you need and hook up the relevant checks to
137+ turborepo via the ` test ` root task so they run on CI. The most common tools
138+ (eslint, prettier, jest, and typescript) are trivial to configure correctly
139+ using shared configs, see the relevant config files [ in the insights
140+ app] ( ./apps/insights ) as a starting point.
141+
142+ 3 . If you are writing a package that will be published:
143+
144+ - Make sure you are dual-exporting cjs and esm correctly, see [ how the lazer
145+ sdk package builds] ( ./lazer/sdk/js/package.json ) (in particular look at the
146+ ` build:cjs ` and ` build:esm ` tasks) for an example for how to do this
147+
148+ - Ensure you have properly configured [ subpath
149+ exports] ( https://nodejs.org/api/packages.html#subpath-exports ) to reference
150+ the esm and cjs outputs so that your package can be consumed correctly in
151+ both environments. Again, see [ the lazer sdk] ( ./lazer/sdk/js/package.json )
152+ as an example for doing this correctly.
153+
154+ - Ensure you have set a ` main ` and ` types ` property on your ` package.json `
155+ pointing to your cjs entrypoint for use in older javascript environments.
156+
157+ - Ensure you configure the ` files ` property on your ` package.json ` to include
158+ all output files and to exclude source files & tooling configuration. This
159+ will result in smaller package sizes.
160+
115161## Audit / Feature Status
116162
117163⚠ ** This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
0 commit comments