forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
204 lines (155 loc) · 5.35 KB
/
Makefile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
MAKEFLAGS = -j1
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
TEST262_COMMIT = ce2dfd49d13740e995c96c34686d45c7960e628c
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
export FORCE_COLOR = true
SOURCES = packages codemods
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
build: clean clean-lib
yarn gulp build
node packages/babel-standalone/scripts/generate.js
node packages/babel-types/scripts/generateTypeHelpers.js
# call build again as the generated files might need to be compiled again.
yarn gulp build
# generate flow and typescript typings
node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts
ifneq ("$(BABEL_COVERAGE)", "true")
make build-standalone
make build-preset-env-standalone
endif
build-standalone:
yarn gulp build-babel-standalone
build-preset-env-standalone:
yarn gulp build-babel-preset-env-standalone
prepublish-build-standalone:
BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-standalone
prepublish-build-preset-env-standalone:
BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-preset-env-standalone
build-dist: build
cd packages/babel-polyfill; \
scripts/build-dist.sh
cd packages/babel-plugin-transform-runtime; \
node scripts/build-dist.js
watch: clean clean-lib
# Ensure that build artifacts for types are created during local
# development too.
BABEL_ENV=development yarn gulp build-no-bundle
node packages/babel-types/scripts/generateTypeHelpers.js
node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts
BABEL_ENV=development yarn gulp watch
flow:
yarn flow check --strip-root
lint: lint-js lint-ts
lint-js:
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe
lint-ts:
scripts/tests/typescript/lint.sh
fix: fix-json
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
fix-json:
yarn prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
clean: test-clean
rm -f .npmrc
rm -rf packages/babel-polyfill/browser*
rm -rf packages/babel-polyfill/dist
rm -rf coverage
rm -rf packages/*/npm-debug*
test-clean:
$(foreach source, $(SOURCES), \
$(call clean-source-test, $(source)))
# Does not work on Windows; use "yarn jest" instead
test-only:
BABEL_ENV=test ./scripts/test.sh
make test-clean
test: lint test-only
test-ci: bootstrap
BABEL_ENV=test yarn jest --maxWorkers=4 --ci
make test-clean
# Does not work on Windows
test-ci-coverage: SHELL:=/bin/bash
test-ci-coverage:
BABEL_COVERAGE=true BABEL_ENV=test make bootstrap
BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
bootstrap-flow:
rm -rf build/flow
mkdir -p build
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git build/flow
cd build/flow && git checkout $(FLOW_COMMIT)
test-flow:
node scripts/tests/flow/run_babel_parser_flow_tests.js
test-flow-ci: bootstrap test-flow
test-flow-update-whitelist:
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist
bootstrap-test262:
rm -rf build/test262
mkdir -p build
git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git build/test262
cd build/test262 && git checkout $(TEST262_COMMIT)
test-test262:
node scripts/tests/test262/run_babel_parser_test262.js
test-test262-ci: bootstrap test-test262
test-test262-update-whitelist:
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
# Does not work on Windows
clone-license:
./scripts/clone-license.sh
prepublish-build:
make clean-lib
rm -rf packages/babel-runtime/helpers
rm -rf packages/babel-runtime-corejs2/helpers
rm -rf packages/babel-runtime-corejs2/core-js
NODE_ENV=production BABEL_ENV=production make build-dist
make clone-license
prepublish:
make bootstrap-only
make prepublish-build
make test
new-version:
git pull --rebase
yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
# NOTE: Run make new-version first
publish: prepublish
yarn lerna publish from-git --require-scripts
make clean
publish-ci: prepublish
ifneq ("$(NPM_TOKEN)", "")
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
else
echo "Missing NPM_TOKEN env var"
exit 1
endif
yarn lerna publish from-git --require-scripts --yes
rm -f .npmrc
make clean
bootstrap-only: clean-all
yarn --ignore-engines
yarn lerna bootstrap -- --ignore-engines
bootstrap: bootstrap-only
make build
cd packages/babel-plugin-transform-runtime; \
node scripts/build-dist.js
clean-lib:
$(foreach source, $(SOURCES), \
$(call clean-source-lib, $(source)))
clean-all:
rm -rf node_modules
rm -rf package-lock.json
rm -rf .changelog
$(foreach source, $(SOURCES), \
$(call clean-source-all, $(source)))
make clean
define clean-source-lib
rm -rf $(1)/*/lib
endef
define clean-source-test
rm -rf $(1)/*/test/tmp
rm -rf $(1)/*/test-fixtures.json
endef
define clean-source-all
rm -rf $(1)/*/lib
rm -rf $(1)/*/node_modules
rm -rf $(1)/*/package-lock.json
endef