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

Add comments to describe the purpose of each section of the code. #16003

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

// Check if the babel.config.js is being loaded during testing
if (
typeof it === "function" &&
// Jest loads the Babel config to parse file and update inline snapshots.
Expand All @@ -12,6 +13,7 @@ if (
const pathUtils = require("path");
const fs = require("fs");

// Helper function to normalize file paths
function normalize(src) {
return src.replace(/\//, pathUtils.sep);
}
Expand Down Expand Up @@ -75,6 +77,7 @@ module.exports = function (api) {
iterableIsArray: true,
};

// Define environment-specific configuration
let targets = {};
let convertESM = outputType === "script";
let replaceTSImportExtension = true;
Expand All @@ -101,6 +104,7 @@ module.exports = function (api) {
"./packages/babel-preset-env/src/available-plugins.js",
];

// Handle different environments
switch (env) {
// Configs used during bundling builds.
case "standalone":
Expand Down Expand Up @@ -324,6 +328,7 @@ module.exports = function (api) {
return config;
};

// Helper function to get monorepo packages
let monorepoPackages;
function getMonorepoPackages() {
if (!monorepoPackages) {
Expand All @@ -335,6 +340,8 @@ function getMonorepoPackages() {
return monorepoPackages;
}


// Helper function to determine import interop strategy for source files
function importInteropSrc(source, filename) {
if (
// These internal files are "real CJS" (whose default export is
Expand All @@ -359,6 +366,8 @@ function importInteropSrc(source, filename) {
return "node";
}


// Helper function to determine import interop strategy for test files
function importInteropTest(source) {
// This file will soon have an esm entrypoint
if (source === "@babel/helper-plugin-test-runner") {
Expand Down