Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only bundle the release build, and don't import src in tests #13978

Merged
merged 4 commits into from Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions .eslintrc.cjs
Expand Up @@ -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/**"] }],
},
},
{
Expand Down
21 changes: 11 additions & 10 deletions Makefile
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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

Expand Down
Expand Up @@ -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`, {
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
@@ -1,4 +1,5 @@
const supportsESM = parseInt(process.versions.node) >= 12;
const isPublishBundle = process.env.IS_PUBLISH;

module.exports = {
collectCoverageFrom: [
Expand All @@ -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"],
Expand Down
@@ -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", () => {
Expand Down
@@ -1,7 +1,7 @@
import {
isKeyword,
keywordRelationalOperator,
} from "../../../src/util/identifier.js";
} from "../../../lib/util/identifier.js";

describe("identifier", () => {
describe("isKeyword", () => {
Expand Down
@@ -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";
Expand Down
@@ -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;
Expand Down
@@ -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;
Expand Down
@@ -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) {
Expand Down
@@ -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", () => {
Expand Down
@@ -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", () => {
Expand Down