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
This commit is contained in:
Nicolò Ribaudo 2021-11-24 16:08:53 +01:00 committed by GitHub
parent 75996cb62b
commit ad1798ed48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 22 deletions

View File

@ -67,10 +67,8 @@ module.exports = {
"jest/no-standalone-expect": "off",
"jest/no-test-callback": "off",
"jest/valid-describe": "off",
"import/extensions": [
"error",
{ json: "always", js: "always", cjs: "always", mjs: "always" },
],
"import/extensions": ["error", "always"],
"no-restricted-imports": ["error", { patterns: ["**/src/**"] }],
},
},
{

View File

@ -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

View File

@ -34,6 +34,7 @@ describe("parserOverride", () => {
const babel7node12 = parseInt(process.versions.node) < 12 ? it.skip : it;
babel7node12("works when parsing in a worker", async () => {
const require = createRequire(import.meta.url);
// eslint-disable-next-line import/extensions
const babelESLintWorker = require("@babel/eslint-parser/experimental-worker");
const { ast } = babelESLintWorker.parseForESLint(`27`, {

View File

@ -1,4 +1,5 @@
const supportsESM = parseInt(process.versions.node) >= 12;
const isPublishBundle = process.env.IS_PUBLISH;
module.exports = {
collectCoverageFrom: [
@ -23,6 +24,9 @@ module.exports = {
"<rootDir>/build/",
"<rootDir>/.history/", // local directory for VSCode Extension - https://marketplace.visualstudio.com/items?itemName=xyz.local-history
"_browser\\.js",
// Some tests require internal files of bundled packages, which are not available
// in production builds. They are marked using the .skip-bundled.js extension.
...(isPublishBundle ? ["\\.skip-bundled\\.js$"] : []),
],
testEnvironment: "node",
setupFilesAfterEnv: ["<rootDir>/test/testSetupFile.js"],

View File

@ -1,4 +1,4 @@
import { tt, tokenOperatorPrecedence } from "../../../src/tokenizer/types.js";
import { tt, tokenOperatorPrecedence } from "../../../lib/tokenizer/types.js";
describe("token types", () => {
it("should check if the binOp for relational === in", () => {

View File

@ -1,7 +1,7 @@
import {
isKeyword,
keywordRelationalOperator,
} from "../../../src/util/identifier.js";
} from "../../../lib/util/identifier.js";
describe("identifier", () => {
describe("isKeyword", () => {

View File

@ -1,4 +1,4 @@
import { getLineInfo } from "../../../src/util/location.js";
import { getLineInfo } from "../../../lib/util/location.js";
describe("getLineInfo", () => {
const input = "a\nb\nc\nd\ne\nf\ng\nh\ni";

View File

@ -1,5 +1,5 @@
import { parseSync, traverse } from "@babel/core";
import { shouldTransform } from "../src/util.ts";
import { shouldTransform } from "../lib/util.js";
function getPath(input, parserOpts = {}) {
let targetPath;

View File

@ -1,5 +1,5 @@
import { parseSync, traverse } from "@babel/core";
import { shouldTransform } from "../src/util.ts";
import { shouldTransform } from "../lib/util.js";
function getPath(input, parserOpts = {}) {
let targetPath;

View File

@ -1,4 +1,4 @@
import { willPathCastToBoolean } from "../src/util.js";
import { willPathCastToBoolean } from "../lib/util.js";
import { parseSync, traverse } from "@babel/core";
function getPath(input, parserOpts) {

View File

@ -1,4 +1,5 @@
import normalizeOptions from "../src/normalize-options.js";
import normalizeOptions from "../lib/normalize-options.js";
describe("normalize options", () => {
(process.env.BABEL_8_BREAKING ? describe : describe.skip)("Babel 8", () => {
it("should throw on unknown options", () => {

View File

@ -1,4 +1,5 @@
import normalizeOptions from "../src/normalize-options.js";
import normalizeOptions from "../lib/normalize-options.js";
describe("normalize options", () => {
(process.env.BABEL_8_BREAKING ? describe : describe.skip)("Babel 8", () => {
it("should throw on unknown options", () => {