Makefile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. MAKEFLAGS = -j1
  2. FLOW_COMMIT = 395e045c18d537fcbbc552a96ef2cdcd70b4ab52
  3. TEST262_COMMIT = 40883f4c6ae17e073dfd03e34f73a6bf8c855595
  4. # Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
  5. export FORCE_COLOR = true
  6. SOURCES = packages codemods
  7. .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
  8. build: clean clean-lib
  9. ./node_modules/.bin/gulp build
  10. node ./packages/babel-types/scripts/generateTypeHelpers.js
  11. # call build again as the generated files might need to be compiled again.
  12. ./node_modules/.bin/gulp build
  13. # generate flow and typescript typings
  14. node scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
  15. node scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
  16. # generate docs
  17. node scripts/generators/docs.js > ./packages/babel-types/README.md
  18. ifneq ("$(BABEL_COVERAGE)", "true")
  19. make build-standalone
  20. make build-preset-env-standalone
  21. endif
  22. build-standalone:
  23. ./node_modules/.bin/gulp build-babel-standalone
  24. build-preset-env-standalone:
  25. ./node_modules/.bin/gulp build-babel-preset-env-standalone
  26. build-dist: build
  27. cd packages/babel-polyfill; \
  28. scripts/build-dist.sh
  29. cd packages/babel-runtime; \
  30. node scripts/build-dist.js
  31. watch: clean clean-lib
  32. # Ensure that build artifacts for types are created during local
  33. # development too.
  34. BABEL_ENV=development ./node_modules/.bin/gulp build-no-bundle
  35. node ./packages/babel-types/scripts/generateTypeHelpers.js
  36. node scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
  37. BABEL_ENV=development ./node_modules/.bin/gulp watch
  38. flow:
  39. ./node_modules/.bin/flow check --strip-root
  40. lint:
  41. ./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --rulesdir="./scripts/eslint_rules"
  42. fix:
  43. ./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --fix --rulesdir="./scripts/eslint_rules"
  44. clean: test-clean
  45. rm -rf packages/babel-polyfill/browser*
  46. rm -rf packages/babel-polyfill/dist
  47. rm -rf coverage
  48. rm -rf packages/*/npm-debug*
  49. test-clean:
  50. $(foreach source, $(SOURCES), \
  51. $(call clean-source-test, $(source)))
  52. test-only:
  53. BABEL_ENV=test ./scripts/test.sh
  54. make test-clean
  55. test: test-only
  56. test-ci: bootstrap test-only
  57. test-ci-coverage: SHELL:=/bin/bash
  58. test-ci-coverage:
  59. BABEL_COVERAGE=true BABEL_ENV=test make bootstrap
  60. BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh
  61. bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
  62. bootstrap-flow:
  63. rm -rf ./build/flow
  64. mkdir -p ./build
  65. git clone --branch=master --single-branch --shallow-since=2017-01-01 https://github.com/facebook/flow.git ./build/flow
  66. cd build/flow && git checkout $(FLOW_COMMIT)
  67. test-flow:
  68. node scripts/tests/flow/run_babel_parser_flow_tests.js
  69. test-flow-ci: bootstrap test-flow
  70. test-flow-update-whitelist:
  71. node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist
  72. bootstrap-test262:
  73. rm -rf ./build/test262
  74. mkdir -p ./build
  75. git clone --branch=master --single-branch --shallow-since=2017-01-01 https://github.com/tc39/test262.git ./build/test262
  76. cd build/test262 && git checkout $(TEST262_COMMIT)
  77. test-test262:
  78. node scripts/tests/test262/run_babel_parser_test262.js
  79. test-test262-ci: bootstrap test-test262
  80. test-test262-update-whitelist:
  81. node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
  82. publish:
  83. git pull --rebase
  84. make clean-lib
  85. rm -rf packages/babel-runtime/helpers
  86. rm -rf packages/babel-runtime/core-js
  87. BABEL_ENV=production make build-dist
  88. make test
  89. # not using lerna independent mode atm, so only update packages that have changed since we use ^
  90. # --only-explicit-updates
  91. ./node_modules/.bin/lerna publish --force-publish=* --exact --skip-temp-tag
  92. make clean
  93. bootstrap: clean-all
  94. yarn --ignore-engines
  95. ./node_modules/.bin/lerna bootstrap -- --ignore-engines
  96. make build
  97. cd packages/babel-runtime; \
  98. node scripts/build-dist.js
  99. clean-lib:
  100. $(foreach source, $(SOURCES), \
  101. $(call clean-source-lib, $(source)))
  102. clean-all:
  103. rm -rf node_modules
  104. rm -rf package-lock.json
  105. rm -rf .changelog
  106. $(foreach source, $(SOURCES), \
  107. $(call clean-source-all, $(source)))
  108. make clean
  109. define clean-source-lib
  110. rm -rf $(1)/*/lib
  111. endef
  112. define clean-source-test
  113. rm -rf $(1)/*/test/tmp
  114. rm -rf $(1)/*/test-fixtures.json
  115. endef
  116. define clean-source-all
  117. rm -rf $(1)/*/lib
  118. rm -rf $(1)/*/node_modules
  119. rm -rf $(1)/*/package-lock.json
  120. endef