Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions _tools/check_mod_exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright 2018-2026 the Deno authors. MIT license.

import { walk } from "../fs/walk.ts";
import { basename } from "../path/basename.ts";
import { relative } from "../path/relative.ts";
import { dirname } from "../path/dirname.ts";
import * as colors from "../fmt/colors.ts";
Expand All @@ -11,6 +12,28 @@ import { fromFileUrl } from "@std/path/from-file-url";

const FAIL_FAST = Deno.args.includes("--fail-fast");

const ROOT = fromFileUrl(new URL("../", import.meta.url));

// Matched against paths relative to ROOT, with `/` separators.
const SKIP = [
/unstable/,
/^dotenv\/load\.ts$/,
/^front_matter\/yaml\.ts$/,
/^front_matter\/json\.ts$/,
/^front_matter\/toml\.ts$/,
/^front_matter\/any\.ts$/,
/^uuid\/v1\.ts$/,
/^uuid\/v3\.ts$/,
/^uuid\/v4\.ts$/,
/^uuid\/v5\.ts$/,
/^uuid\/v7\.ts$/,
/_test\.ts$/,
/_bench\.ts$/,
/\.d\.ts$/,
/\/_/,
/\/mod\.ts$/,
];

let shouldFail = false;

const MOD_FILE_PATHS = (await getEntrypoints())
Expand All @@ -24,7 +47,7 @@ for (const modFilePath of MOD_FILE_PATHS) {
modSource,
ts.ScriptTarget.Latest,
);
const modExportSpecifiers = new Set();
const modExportSpecifiers = new Set<string>();
modSourceFile.forEachChild((node) => {
if (
ts.isExportDeclaration(node) &&
Expand All @@ -40,29 +63,12 @@ for (const modFilePath of MOD_FILE_PATHS) {
exts: [".ts"],
includeDirs: false,
maxDepth: 1,
skip: [
/unstable/,
/dotenv(\/|\\)load\.ts$/,
/front_matter(\/|\\)yaml\.ts$/,
/front_matter(\/|\\)json\.ts$/,
/front_matter(\/|\\)toml\.ts$/,
/front_matter(\/|\\)any\.ts$/,
/uuid(\/|\\)v1\.ts$/,
/uuid(\/|\\)v3\.ts$/,
/uuid(\/|\\)v4\.ts$/,
/uuid(\/|\\)v5\.ts$/,
/uuid(\/|\\)v6\.ts$/,
/uuid(\/|\\)v7\.ts$/,
/_test\.ts$/,
/_bench\.ts$/,
/\.d\.ts$/,
/(\/|\\)_/,
/mod\.ts$/,
],
})
) {
const relativeSpecifier = relative(modFilePath, filePath).slice(1)
.replaceAll("\\", "/");
const relativePath = relative(ROOT, filePath).replaceAll("\\", "/");
if (SKIP.some((pattern) => pattern.test(relativePath))) continue;

const relativeSpecifier = `./${basename(filePath)}`;

if (!modExportSpecifiers.has(relativeSpecifier)) {
if (
Expand Down
Loading