diff --git a/Makefile b/Makefile index 6936a21e86ae..ebc19d39ab78 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ NODE := $(YARN) node .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap -build: build-bundle +build: build-no-bundle ifneq ("$(BABEL_COVERAGE)", "true") $(MAKE) build-standalone endif @@ -28,8 +28,15 @@ build-bundle: clean clean-lib $(MAKE) build-flow-typings $(MAKE) build-dist -build-bundle-ci: bootstrap-only - $(MAKE) 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 + BABEL_ENV=development $(YARN) gulp build-dev + $(MAKE) build-flow-typings + $(MAKE) build-dist generate-tsconfig: $(NODE) scripts/generators/tsconfig.js @@ -46,7 +53,7 @@ build-typescript-legacy-typings: build-standalone: build-babel-standalone -build-standalone-ci: build-bundle-ci +build-standalone-ci: build-no-bundle-ci $(MAKE) build-standalone build-babel-standalone: @@ -61,12 +68,6 @@ build-plugin-transform-runtime-dist: cd packages/babel-plugin-transform-runtime; \ $(NODE) scripts/build-dist.js -build-no-bundle: clean clean-lib - BABEL_ENV=development $(YARN) gulp build-dev - # Ensure that build artifacts for types are created during local - # development too. - $(MAKE) build-flow-typings - watch: build-no-bundle BABEL_ENV=development $(YARN) gulp watch diff --git a/babel.config.js b/babel.config.js index 5ea6cfb229e9..60fa06968635 100644 --- a/babel.config.js +++ b/babel.config.js @@ -215,6 +215,10 @@ module.exports = function (api) { assumptions: sourceAssumptions, plugins: [transformNamedBabelTypesImportToDestructuring], }, + { + test: sources.map(source => normalize(source.replace("/src", "/test"))), + plugins: ["@babel/plugin-proposal-dynamic-import"], + }, { test: unambiguousSources.map(normalize), sourceType: "unambiguous", diff --git a/packages/babel-parser/test/unit/tokenizer/types.js b/packages/babel-parser/test/unit/tokenizer/types.js index 1b54dda5966e..da3b291b28a6 100644 --- a/packages/babel-parser/test/unit/tokenizer/types.js +++ b/packages/babel-parser/test/unit/tokenizer/types.js @@ -1,6 +1,13 @@ -import { tt, tokenOperatorPrecedence } from "../../../src/tokenizer/types"; +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("token types", () => { + let tt, tokenOperatorPrecedence; + beforeAll(async () => { + ({ tt, tokenOperatorPrecedence } = await import( + "../../../lib/tokenizer/types" + )); + }); -describe("token types", () => { it("should check if the binOp for relational === in", () => { expect(tokenOperatorPrecedence(tt.relational)).toEqual( tokenOperatorPrecedence(tt._in), diff --git a/packages/babel-parser/test/unit/util/identifier.js b/packages/babel-parser/test/unit/util/identifier.js index 420971a577e9..6c0a1fa446fd 100644 --- a/packages/babel-parser/test/unit/util/identifier.js +++ b/packages/babel-parser/test/unit/util/identifier.js @@ -1,9 +1,13 @@ -import { - isKeyword, - keywordRelationalOperator, -} from "../../../src/util/identifier"; +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("identifier", () => { + let isKeyword, keywordRelationalOperator; + beforeAll(async () => { + ({ isKeyword, keywordRelationalOperator } = await import( + "../../../lib/util/identifier" + )); + }); -describe("identifier", () => { describe("isKeyword", () => { it("break is a keyword", () => { expect(isKeyword("break")).toBe(true); diff --git a/packages/babel-parser/test/unit/util/location.js b/packages/babel-parser/test/unit/util/location.js index f66d3a3204eb..43cabbc043fe 100644 --- a/packages/babel-parser/test/unit/util/location.js +++ b/packages/babel-parser/test/unit/util/location.js @@ -1,6 +1,11 @@ -import { getLineInfo } from "../../../src/util/location"; +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("getLineInfo", () => { + let getLineInfo; + beforeAll(async () => { + ({ getLineInfo } = await import("../../../lib/util/location")); + }); -describe("getLineInfo", () => { const input = "a\nb\nc\nd\ne\nf\ng\nh\ni"; it("reports correct position", () => { diff --git a/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/test/util.test.js b/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/test/util.test.js index f6e9282e42fa..159823460d96 100644 --- a/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/test/util.test.js +++ b/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/test/util.test.js @@ -1,5 +1,4 @@ import { parseSync, traverse } from "@babel/core"; -import { shouldTransform } from "../src/util.ts"; function getPath(input, parserOpts = {}) { let targetPath; @@ -19,7 +18,14 @@ function getPath(input, parserOpts = {}) { return targetPath; } -describe("shouldTransform", () => { +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("shouldTransform", () => { + let shouldTransform; + beforeAll(async () => { + ({ shouldTransform } = await import("../lib/util")); + }); + const positiveCases = [ "(function a([a]) {})", "({ b: function a([a]) {} })", diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/util.test.js b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/util.test.js index 89bc17afb5d7..6058149bf7c1 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/util.test.js +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/util.test.js @@ -1,5 +1,4 @@ import { parseSync, traverse } from "@babel/core"; -import { shouldTransform } from "../src/util.ts"; function getPath(input, parserOpts = {}) { let targetPath; @@ -20,7 +19,14 @@ function getPath(input, parserOpts = {}) { return targetPath; } -describe("shouldTransform", () => { +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("shouldTransform", () => { + let shouldTransform; + beforeAll(async () => { + ({ shouldTransform } = await import("../lib/util")); + }); + const positiveCases = [ "fn?.(...[], 0)", "fn?.(...[], ...[])", diff --git a/packages/babel-plugin-proposal-optional-chaining/test/util.test.js b/packages/babel-plugin-proposal-optional-chaining/test/util.test.js index fbf99d64e52e..788a38daabe3 100644 --- a/packages/babel-plugin-proposal-optional-chaining/test/util.test.js +++ b/packages/babel-plugin-proposal-optional-chaining/test/util.test.js @@ -1,4 +1,3 @@ -import { willPathCastToBoolean } from "../src/util"; import { parseSync, traverse } from "@babel/core"; function getPath(input, parserOpts) { @@ -13,7 +12,14 @@ function getPath(input, parserOpts) { return targetPath; } -describe("willPathCastToBoolean", () => { +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("willPathCastToBoolean", () => { + let willPathCastToBoolean; + beforeAll(async () => { + ({ willPathCastToBoolean } = await import("../lib/util")); + }); + const positiveCases = [ "if(a?.b) {}", "while(a?.b) {}", diff --git a/packages/babel-preset-react/test/normalize-options.spec.js b/packages/babel-preset-react/test/normalize-options.spec.js index f042f13790c9..02971c5288f9 100644 --- a/packages/babel-preset-react/test/normalize-options.spec.js +++ b/packages/babel-preset-react/test/normalize-options.spec.js @@ -1,5 +1,11 @@ -import normalizeOptions from "../src/normalize-options"; -describe("normalize options", () => { +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("normalize options", () => { + let normalizeOptions; + beforeAll(async () => { + ({ default: normalizeOptions } = await import("../lib/normalize-options")); + }); + (process.env.BABEL_8_BREAKING ? describe : describe.skip)("Babel 8", () => { it("should throw on unknown options", () => { expect(() => normalizeOptions({ throwIfNamespaces: true })).toThrowError( diff --git a/packages/babel-preset-typescript/test/normalize-options.spec.js b/packages/babel-preset-typescript/test/normalize-options.spec.js index 189af1ee3414..99462a42c57d 100644 --- a/packages/babel-preset-typescript/test/normalize-options.spec.js +++ b/packages/babel-preset-typescript/test/normalize-options.spec.js @@ -1,5 +1,11 @@ -import normalizeOptions from "../src/normalize-options"; -describe("normalize options", () => { +const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe; + +describeSkipPublish("normalize options", () => { + let normalizeOptions; + beforeAll(async () => { + ({ default: normalizeOptions } = await import("../lib/normalize-options")); + }); + (process.env.BABEL_8_BREAKING ? describe : describe.skip)("Babel 8", () => { it("should throw on unknown options", () => { expect(() => normalizeOptions({ allowNamespace: true })).toThrowError(