-
Notifications
You must be signed in to change notification settings - Fork 35
/
postinstall.js
35 lines (29 loc) · 1.1 KB
/
postinstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// @ts-check
/**
* Keeps the .nvmrc file in sync with the node version defined in the volta config in the monorepo's package.json
*/
const { writeFileSync } = require('node:fs');
const {
volta: { node: nodeVersion },
} = require('./package.json');
writeFileSync('./.nvmrc', `${nodeVersion}\n`);
/**
* Keeps the current node target for use with `@babel/preset-env` in sync with the node version defined in the
* engines config in sku's package.json. `browserlist` doesn't seem to support node 18.20 yet, so
* for now it's just using the major version.
*/
const {
engines: { node },
} = require('./packages/sku/package.json');
const [, minimumSupportedVersion] = node.split('=');
const targets = {
// https://github.com/browserslist/browserslist?tab=readme-ov-file#full-list
browserslistNodeTarget: `node ${minimumSupportedVersion}`,
// https://esbuild.github.io/api/#target
esbuildNodeTarget: `node${minimumSupportedVersion}`,
};
const prettier = require('prettier');
writeFileSync(
'./packages/sku/config/targets.json',
prettier.format(JSON.stringify(targets, null, 2), { parser: 'json' }),
);