-
Notifications
You must be signed in to change notification settings - Fork 524
/
package-scripts.js
60 lines (56 loc) · 2.33 KB
/
package-scripts.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* We generally use `nps` for scripts that we:
* 1. define at the root of the monorepo
* 2. that are meant to execute _within_ a workspace
*
* ... or ...
*
* - That could use a little JS magic that we don't want to write a full
* node script for 😂
*
* For more cases, if you have an actual root task, define it in root
* `package.json:scripts`.
*/
// For publishing, use the core package's version.
const coreVersion = require("./packages/victory-core/package.json").version;
if (!coreVersion) {
throw new Error("Unable to read core version");
}
const coreTag = `v${coreVersion}`;
module.exports = {
scripts: {
// Root tasks.
// Try to find an existing tag (from previous attempts, etc.), and if not, create one.
"git:tag": `git show-ref ${coreTag} || git tag -a ${coreTag} -m \"Version ${coreVersion}\"`,
// Build.
// - Libraries
"build:lib:esm":
"cross-env BABEL_ENV=es babel src --out-dir es --config-file ../../.babelrc.build.js --extensions .tsx,.ts,.jsx,.js",
"build:lib:cjs":
"cross-env BABEL_ENV=commonjs babel src --out-dir lib --config-file ../../.babelrc.build.js --extensions .tsx,.ts,.jsx,.js",
// - UMD distributions
// TODO(2375): Add / verify caching
// https://github.com/FormidableLabs/victory/issues/2375
"build:dist:dev":
"webpack --bail --config ../../config/webpack/webpack.config.dev.js",
"build:dist:min":
"webpack --bail --config ../../config/webpack/webpack.config.js",
// - TypeScript
// TODO(2375): Can we cache / incremental?
// https://github.com/FormidableLabs/victory/issues/2375
// Check for errors (includes test files):
"types:pkg:check": "tsc --pretty --noEmit",
// To create types, we must do the following:
// 1. Copy all *.d.ts files to the es folder
// 2. Compile all *.ts files to the es folder
// 3. Copy all output from the es folder to the lib folder
"types:pkg:create":
"nps types:pkg:copy types:pkg:compile types:pkg:cjs-copy",
"types:pkg:copy": 'cpx "src/**/*.d.ts" es',
"types:pkg:compile":
"tsc --pretty -p ./tsconfig.build.json --emitDeclarationOnly --rootDir src --outDir es || nps types:warning",
"types:warning":
'echo "Warning: found TypeScript errors during build. Continuing anyway!"',
"types:pkg:cjs-copy": 'cpx "es/**/*{.d.ts,.d.ts.map}" lib',
},
};