Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Jul 24, 2022
1 parent db5a299 commit 739c7dc
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 133 deletions.
205 changes: 72 additions & 133 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,110 +14,127 @@ COMMA_SEPARATED_SOURCES = $(subst $(SPACE),$(COMMA),$(SOURCES))

YARN := yarn
NODE := $(YARN) node
MAKEJS := node Makefile.mjs


.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap use-esm use-cjs

build: build-no-bundle
ifneq ("$(BABEL_COVERAGE)", "true")
$(MAKE) build-standalone
endif
build:
$(MAKEJS) build

build-bundle: clean clean-lib
node ./scripts/set-module-type.js
$(YARN) gulp build
$(MAKE) build-flow-typings
$(MAKE) build-dist
build-bundle:
$(MAKEJS) build-bundle

build-no-bundle-ci: bootstrap-only
$(YARN) gulp build-dev
$(MAKE) build-flow-typings
$(MAKE) build-dist

build-no-bundle: clean clean-lib
node ./scripts/set-module-type.js
BABEL_ENV=development $(YARN) gulp build-dev
$(MAKE) build-flow-typings
$(MAKE) build-dist
build-no-bundle:
$(MAKEJS) build-no-bundle

generate-tsconfig:
$(NODE) scripts/generators/tsconfig.js
$(NODE) scripts/generators/archived-libs-typings.js
$(MAKEJS) generate-tsconfig

generate-type-helpers:
$(YARN) gulp generate-type-helpers
$(MAKEJS) generate-type-helpers

build-flow-typings:
$(NODE) packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
$(MAKEJS) build-flow-typings

# For TypeScript older than 3.7
build-typescript-legacy-typings:
$(NODE) packages/babel-types/scripts/generators/typescript-legacy.js > packages/babel-types/lib/index-legacy.d.ts
$(MAKEJS) build-typescript-legacy-typings

build-standalone: build-babel-standalone
build-standalone:
$(MAKEJS) build-standalone

build-standalone-ci: build-no-bundle-ci
$(MAKE) build-standalone

build-babel-standalone:
$(YARN) gulp build-babel-standalone
$(MAKEJS) build-standalone

prepublish-build-standalone:
BABEL_ENV=production IS_PUBLISH=true $(YARN) gulp build-babel-standalone
$(MAKEJS) prepublish-build-standalone

build-dist: build-plugin-transform-runtime-dist

build-plugin-transform-runtime-dist:
cd packages/babel-plugin-transform-runtime; \
$(NODE) scripts/build-dist.js
$(MAKEJS) build-plugin-transform-runtime-dist

watch: build-no-bundle
BABEL_ENV=development WATCH_SKIP_BUILD=true $(YARN) gulp watch
watch:
$(MAKEJS) watch

code-quality: tscheck lint

tscheck: generate-tsconfig
rm -rf dts
$(YARN) tsc -b .
tscheck:
$(MAKEJS) tscheck

lint-ci: lint check-compat-data-ci

check-compat-data-ci:
$(MAKE) check-compat-data
check-compat-data-ci: check-compat-data

lint:
BABEL_ENV=test $(YARN) eslint scripts benchmark $(SOURCES) '*.{js,cjs,mjs,ts}' --format=codeframe --ext .js,.cjs,.mjs,.ts
$(MAKEJS) lint

fix: fix-json fix-js

fix-js:
$(YARN) eslint scripts benchmark $(SOURCES) '*.{js,cjs,mjs,ts}' --format=codeframe --ext .js,.cjs,.mjs,.ts --fix
$(MAKEJS) fix-js

fix-json:
$(YARN) prettier "{$(COMMA_SEPARATED_SOURCES)}/*/test/fixtures/**/options.json" --write --loglevel warn
$(MAKEJS) fix-json

check-compat-data:
cd packages/babel-compat-data; CHECK_COMPAT_DATA=true $(YARN) run build-data
clean:
$(MAKEJS) clean

build-compat-data:
cd packages/babel-compat-data; $(YARN) run build-data
test: lint test-only

clone-license:
$(MAKEJS) clone-license

prepublish-build:
$(MAKEJS) prepublish-build

prepublish:
$(MAKEJS) prepublish-build

clean: test-clean
rm -f .npmrc
rm -rf coverage
rm -rf packages/*/npm-debug*
rm -rf node_modules/.cache
bootstrap-only:
$(MAKEJS) bootstrap-only

test-clean:
$(foreach source, $(SOURCES), \
$(call clean-source-test, $(source)))
bootstrap:
$(MAKEJS) bootstrap

use-cjs:
$(MAKEJS) use-cjs

use-esm:
$(MAKEJS) use-esm

clean-lib:
$(MAKEJS) clean-lib

clean-runtime-helpers:
$(MAKEJS) clean-runtime-helpers

clean-all:
$(MAKEJS) clean-all


build-no-bundle-ci: bootstrap-only
$(YARN) gulp build-dev
$(MAKE) build-flow-typings
$(MAKE) build-dist

# Does not work on Windows; use "$(YARN) jest" instead
test-only:
BABEL_ENV=test ./scripts/test.sh
$(MAKE) test-clean

test: lint test-only
check-compat-data:
cd packages/babel-compat-data; CHECK_COMPAT_DATA=true $(YARN) run build-data

build-compat-data:
cd packages/babel-compat-data; $(YARN) run build-data

update-env-corejs-fixture:
rm -rf packages/babel-preset-env/node_modules/core-js-compat
$(YARN)
$(MAKE) build-bundle
OVERWRITE=true $(YARN) jest packages/babel-preset-env

test-ci: build-standalone-ci
BABEL_ENV=test $(YARN) jest --maxWorkers=4 --ci
Expand Down Expand Up @@ -165,23 +182,6 @@ test-test262:
test-test262-update-allowlist:
$(NODE) scripts/parser-tests/test262 --update-allowlist

clone-license:
$(NODE) ./scripts/clone-license.js

prepublish-build: clean-lib clean-runtime-helpers
NODE_ENV=production BABEL_ENV=production STRIP_BABEL_8_FLAG=true $(MAKE) build-bundle
STRIP_BABEL_8_FLAG=true $(MAKE) prepublish-build-standalone clone-license prepublish-prepare-dts

prepublish-prepare-dts:
$(MAKE) tscheck
$(YARN) gulp bundle-dts
$(MAKE) build-typescript-legacy-typings

prepublish:
$(MAKE) bootstrap-only
$(MAKE) prepublish-build
IS_PUBLISH=true $(MAKE) test
node ./scripts/set-module-type.js clean

new-version-checklist:
# @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Expand Down Expand Up @@ -220,64 +220,3 @@ endif
node ./scripts/set-module-type.js clean
YARN_NPM_PUBLISH_REGISTRY=http://localhost:4873 $(YARN) release-tool publish --yes --tag-version-prefix="version-e2e-test-"
$(MAKE) clean

bootstrap-only: clean-all
$(YARN) install

bootstrap: bootstrap-only
$(MAKE) generate-tsconfig build

use-cjs:
node ./scripts/set-module-type.js script
$(MAKE) bootstrap

use-esm:
node ./scripts/set-module-type.js module
$(MAKE) bootstrap

clean-lib:
$(foreach source, $(SOURCES), \
$(call clean-source-lib, $(source)))

clean-runtime-helpers:
rm -f packages/babel-runtime/helpers/**/*.js
rm -f packages/babel-runtime-corejs2/helpers/**/*.js
rm -f packages/babel-runtime-corejs3/helpers/**/*.js
rm -f packages/babel-runtime/helpers/**/*.mjs
rm -f packages/babel-runtime-corejs2/helpers/**/*.mjs
rm -f packages/babel-runtime-corejs3/helpers/**/*.mjs
rm -rf packages/babel-runtime-corejs2/core-js

clean-all:
rm -rf node_modules
rm -rf package-lock.json
rm -rf .changelog

$(foreach source, $(SOURCES), \
$(call clean-source-all, $(source)))

$(MAKE) clean

update-env-corejs-fixture:
rm -rf packages/babel-preset-env/node_modules/core-js-compat
$(YARN)
$(MAKE) build-bundle
OVERWRITE=true $(YARN) jest packages/babel-preset-env

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
$(call clean-source-lib, $1)
rm -rf $(1)/*/node_modules
rm -rf $(1)/*/package-lock.json

endef
39 changes: 39 additions & 0 deletions Makefile.source.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ target["generate-tsconfig"] = function () {
node(["scripts/generators/archived-libs-typings.js"]);
};

target["generate-type-helpers"] = function () {
yarn(["gulp", "generate-type-helpers"]);
};

target["clone-license"] = function () {
node(["scripts/clone-license.js"]);
};
Expand Down Expand Up @@ -357,3 +361,38 @@ target["test"] = function () {
target["test-only"] = function (args = []) {
yarn(["jest", ...args]);
};

/**
* PUBLISH
*/

target["new-version-checklist"] = function () {
if (0) {
throw new Error(
`
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!! !!!!!!
!!!!!! Write any message that should !!!!!!
!!!!!! block the release here !!!!!!
!!!!!! !!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
`.trim()
);
}
};

target["new-version"] = function () {
target["new-version-checklist"]();

exec("git", ["pull", "--rebase"]);
yarn(["release-tool", "version", "-f", "@babel/standalone"]);
};

target["new-version"] = function () {
target["new-version-checklist"]();

exec("git", ["pull", "--rebase"]);
yarn(["release-tool", "version", "-f", "@babel/standalone"]);
};

0 comments on commit 739c7dc

Please sign in to comment.