Skip to content

Commit ad1798e

Browse files
Only bundle the release build, and don't import src in tests (#13978)
* Only bundle the release build, and don't import `src` in tests * Use file extension to signal skipping * Remove unnecessary config change * Fix imports
1 parent 75996cb commit ad1798e

12 files changed

Lines changed: 28 additions & 22 deletions

File tree

.eslintrc.cjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ module.exports = {
6767
"jest/no-standalone-expect": "off",
6868
"jest/no-test-callback": "off",
6969
"jest/valid-describe": "off",
70-
"import/extensions": [
71-
"error",
72-
{ json: "always", js: "always", cjs: "always", mjs: "always" },
73-
],
70+
"import/extensions": ["error", "always"],
71+
"no-restricted-imports": ["error", { patterns: ["**/src/**"] }],
7472
},
7573
},
7674
{

Makefile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ NODE := $(YARN) node
1818

1919
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
2020

21-
build: build-bundle
21+
build: build-no-bundle
2222
ifneq ("$(BABEL_COVERAGE)", "true")
2323
$(MAKE) build-standalone
2424
endif
@@ -28,8 +28,15 @@ build-bundle: clean clean-lib
2828
$(MAKE) build-flow-typings
2929
$(MAKE) build-dist
3030

31-
build-bundle-ci: bootstrap-only
32-
$(MAKE) build-bundle
31+
build-no-bundle-ci: bootstrap-only
32+
$(YARN) gulp build-dev
33+
$(MAKE) build-flow-typings
34+
$(MAKE) build-dist
35+
36+
build-no-bundle: clean clean-lib
37+
BABEL_ENV=development $(YARN) gulp build-dev
38+
$(MAKE) build-flow-typings
39+
$(MAKE) build-dist
3340

3441
generate-tsconfig:
3542
$(NODE) scripts/generators/tsconfig.js
@@ -46,7 +53,7 @@ build-typescript-legacy-typings:
4653

4754
build-standalone: build-babel-standalone
4855

49-
build-standalone-ci: build-bundle-ci
56+
build-standalone-ci: build-no-bundle-ci
5057
$(MAKE) build-standalone
5158

5259
build-babel-standalone:
@@ -61,12 +68,6 @@ build-plugin-transform-runtime-dist:
6168
cd packages/babel-plugin-transform-runtime; \
6269
$(NODE) scripts/build-dist.js
6370

64-
build-no-bundle: clean clean-lib
65-
BABEL_ENV=development $(YARN) gulp build-dev
66-
# Ensure that build artifacts for types are created during local
67-
# development too.
68-
$(MAKE) build-flow-typings
69-
7071
watch: build-no-bundle
7172
BABEL_ENV=development $(YARN) gulp watch
7273

eslint/babel-eslint-tests/test/integration/parser-override.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe("parserOverride", () => {
3434
const babel7node12 = parseInt(process.versions.node) < 12 ? it.skip : it;
3535
babel7node12("works when parsing in a worker", async () => {
3636
const require = createRequire(import.meta.url);
37+
// eslint-disable-next-line import/extensions
3738
const babelESLintWorker = require("@babel/eslint-parser/experimental-worker");
3839

3940
const { ast } = babelESLintWorker.parseForESLint(`27`, {

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const supportsESM = parseInt(process.versions.node) >= 12;
2+
const isPublishBundle = process.env.IS_PUBLISH;
23

34
module.exports = {
45
collectCoverageFrom: [
@@ -23,6 +24,9 @@ module.exports = {
2324
"<rootDir>/build/",
2425
"<rootDir>/.history/", // local directory for VSCode Extension - https://marketplace.visualstudio.com/items?itemName=xyz.local-history
2526
"_browser\\.js",
27+
// Some tests require internal files of bundled packages, which are not available
28+
// in production builds. They are marked using the .skip-bundled.js extension.
29+
...(isPublishBundle ? ["\\.skip-bundled\\.js$"] : []),
2630
],
2731
testEnvironment: "node",
2832
setupFilesAfterEnv: ["<rootDir>/test/testSetupFile.js"],

packages/babel-parser/test/unit/tokenizer/types.js renamed to packages/babel-parser/test/unit/tokenizer/types.skip-bundled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { tt, tokenOperatorPrecedence } from "../../../src/tokenizer/types.js";
1+
import { tt, tokenOperatorPrecedence } from "../../../lib/tokenizer/types.js";
22

33
describe("token types", () => {
44
it("should check if the binOp for relational === in", () => {

packages/babel-parser/test/unit/util/identifier.js renamed to packages/babel-parser/test/unit/util/identifier.skip-bundled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
isKeyword,
33
keywordRelationalOperator,
4-
} from "../../../src/util/identifier.js";
4+
} from "../../../lib/util/identifier.js";
55

66
describe("identifier", () => {
77
describe("isKeyword", () => {

packages/babel-parser/test/unit/util/location.js renamed to packages/babel-parser/test/unit/util/location.skip-bundled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getLineInfo } from "../../../src/util/location.js";
1+
import { getLineInfo } from "../../../lib/util/location.js";
22

33
describe("getLineInfo", () => {
44
const input = "a\nb\nc\nd\ne\nf\ng\nh\ni";

packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/test/util.test.js renamed to packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/test/util.skip-bundled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseSync, traverse } from "@babel/core";
2-
import { shouldTransform } from "../src/util.ts";
2+
import { shouldTransform } from "../lib/util.js";
33

44
function getPath(input, parserOpts = {}) {
55
let targetPath;

packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/util.test.js renamed to packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/util.skip-bundled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseSync, traverse } from "@babel/core";
2-
import { shouldTransform } from "../src/util.ts";
2+
import { shouldTransform } from "../lib/util.js";
33

44
function getPath(input, parserOpts = {}) {
55
let targetPath;

packages/babel-plugin-proposal-optional-chaining/test/util.test.js renamed to packages/babel-plugin-proposal-optional-chaining/test/util.skip-bundled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { willPathCastToBoolean } from "../src/util.js";
1+
import { willPathCastToBoolean } from "../lib/util.js";
22
import { parseSync, traverse } from "@babel/core";
33

44
function getPath(input, parserOpts) {

0 commit comments

Comments
 (0)