Your Vibe-Coded Site Shipped the Source Maps. I Wrote a Checker.
This morning on X, Danylo Dudchenko posted Vibecoder Security Tip #21: turn off source maps before you ship. The live site, he wrote, should only have the shrunk, unreadable version of your code. Source maps hand anyone
This morning on X, Danylo Dudchenko posted Vibecoder Security Tip #21: turn off source maps before you ship. The live site, he wrote, should only have the shrunk, unreadable version of your code. Source maps hand anyone the original files, the comments, and every hidden page the app talks to. AI hacking tools download them.
That is not an exotic attack. It is a default that survived the trip from "preview this locally" to "this folder is the production site." Vite will emit a .map file next to every bundle if build.sourcemap is true. Next.js will do the same when productionBrowserSourceMaps is on. The JavaScript ends with a comment, //# sourceMappingURL=index-a8f3c1.js.map, so DevTools can un-minify the file. Anyone else can un-minify it too. They do not need to bypass a firewall. They request the same URL the browser already told them about, or they guess bundle.js.map beside bundle.js.
A coding agent makes this easier to miss. The preview in Cursor, Claude Code, Lovable, or Bolt is more pleasant with maps on. The first production build often reuses that config. I keep seeing the same "fix" come back from a follow-up prompt: change sourcemap: true to sourcemap: 'hidden'. Vite still writes the .map files. It only omits the comment. If you deploy the output folder, the maps stay public at predictable URLs.
So I wrote the kind of site a coding agent produces for "a bookbindery in Hudson, New York, with a marketing homepage and an internal queue for orders." The homepage looks finished. The bundled JavaScript is minified. Then I left in the things I keep finding in vibe-coded production folders: build.sourcemap: true, a sourceMappingURL comment, and a map whose sourcesContent still holds the original TypeScript — including a service-role value, a local /Users/mira/... path, and routes named /internal/bindery-queue and /preview/invoice.
Then I wrote a short checker, sourcemap_check.py, that reads the local tree and reports whether this build is safe to ship. I ran it on the site as the agent handed it over, on the same tree after I only switched the Vite flag to 'hidden', and on a version with sourcemap: false and the map files removed. All the numbers below come from those three runs. The script never opens a network connection.
The fixture
The business is fictional. It is called Crowstep Bookbindery, and it does custom cloth and leather binding at 12 Warren Street in Hudson, New York. The public site is a Vite + React marketing page. The host crowstepbookbindery.example will not resolve.
The "before" tree looks like a normal production export. dist/index.html references minified assets. The JavaScript is an IIFE that logs the shop name. The part that fails a ship check is not a missing title. It is that the assets still end with sourceMappingURL, the maps still embed original source, and vite.config.ts will happily emit both again on the next build.
Here is the file the JavaScript source map is carrying. The service-role string is a fixture, not a real key.
// Crowstep Bookbindery — internal tools.
// TODO: stop using the service role in the client before launch.
export const SUPABASE_SERVICE_ROLE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.fixture-crowstep-not-a-real-key";
export const INTERNAL_PATHS = {
queue: "/internal/bindery-queue",
invoices: "/preview/invoice",
};
export function openQueue() {
window.location.href = INTERNAL_PATHS.queue;
}
A stranger who fetches index-a8f3c1.js.map does not have to guess that this file exists. The map lists it, and sourcesContent includes the full text. That is the difference between a minified bundle and a public copy of your repo.
A checker that does not leave your repo
sourcemap_check.py walks a project, reads .map files, looks for sourceMappingURL comments in JS and CSS, and inspects Vite, Next.js, and webpack configs. It flags:
-
.mapfiles in the tree, including maps that already embedsourcesContent -
sourceMappingURLcomments, including inline data-URI maps - a comment that points at a map that is not in this tree (a dangling URL, which may still be live on a CDN)
- secrets in mapped source: Stripe secret keys, AWS access keys, private key blocks, GitHub tokens, Google API keys, and
SERVICE_ROLE/SUPABASE_SERVICE_ROLEassignments - local filesystem paths such as
/Users/...orC:\\Users\\... - internal-looking routes in mapped source, such as
/internal/...or/preview/invoice -
build.sourcemapset totrue,'inline', or'hidden'in a Vite config -
productionBrowserSourceMaps: truein a Next.js config - a webpack
devtoolset to a source-map mode (includinghidden-source-map, which still writes the files)
It skips node_modules and .git. It does not fetch the live site, and it does not claim your CDN is clean. A clean run means the local files are not shipping maps. Whether an older deploy is still serving last week's .map is a different job.
The script is 836 lines, with 18 tests.
Run it against a checkout:
python3 sourcemap_check.py ./my-app
# python3 sourcemap_check.py --json ./my-app
# python3 sourcemap_check.py --self-test
#!/usr/bin/env python3
"""sourcemap_check.py — flag production source maps in a local build tree.
Reads files on disk only. It does not open a network connection or fetch
a live site. A clean run means this checkout is not shipping maps, original
source, or a production config that will emit them on the next build.
"""
from __future__ import annotations
import argparse
import base64
import json
import re
import shutil
import sys
import tempfile
import textwrap
import unittest
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Iterable
from urllib.parse import unquote
SKIP_DIRS = {
".git",
"node_modules",
"__pycache__",
".venv",
"venv",
".tox",
".mypy_cache",
".pytest_cache",
"coverage",
}
ASSET_SUFFIXES = {".js", ".mjs", ".cjs", ".css", ".jsx", ".tsx", ".html", ".htm"}
CONFIG_NAMES = {
"vite.config.ts",
"vite.config.js",
"vite.config.mjs",
"vite.config.cjs",
"next.config.js",
"next.config.mjs",
"next.config.ts",
"next.config.cjs",
"webpack.config.js",
"webpack.config.ts",
"webpack.config.mjs",
"webpack.config.cjs",
"nuxt.config.ts",
"nuxt.config.js",
"astro.config.ts",
"astro.config.mjs",
"svelte.config.js",
"angular.json",
}
SOURCEMAPPING_RE = re.compile(
r"(?://|#|/\*)[@#]\s*sourceMappingURL\s*=\s*(\S+?)\s*(?:\*/)?\s*$",
re.MULTILINE,
)
PATH_RE = re.compile(
r"(?:/Users/[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*"
r"|/home/[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*"
r"|C:\\Users\\[A-Za-z0-9._-]+(?:\\[A-Za-z0-9._-]+)*)"
)
HIDDEN_ROUTE_RE = re.compile(
r"/(?:admin|internal|debug|staging|backoffice|hidden|private|drafts?|cms)"
r"(?:/[A-Za-z0-9._~-][A-Za-z0-9._~/-]*)?",
re.I,
)
PREVIEW_ROUTE_RE = re.compile(
r"/preview/(?:invoice|invoices|order|orders|draft|admin|internal|hidden)\b",
re.I,
)
SECRET_RULES = [
(
"stripe_secret",
re.compile(r"sk_(?:live|test)_[0-9A-Za-z]{16,}"),
"A Stripe secret key is embedded in the mapped source.",
),
(
"aws_access_key",
re.compile(r"\bAKIA[0-9A-Z]{16}\b"),
"An AWS access key id is embedded in the mapped source.",
),
(
"private_key",
re.compile(r"-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----"),
"A private key block is embedded in the mapped source.",
),
(
"github_token",
re.compile(r"\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}\b"),
"A GitHub token is embedded in the mapped source.",
),
(
"google_api_key",
re.compile(r"\bAIza[0-9A-Za-z_-]{35}\b"),
"A Google API key is embedded in the mapped source.",
),
(
"service_role_assign",
re.compile(
r"(?:SERVICE_ROLE(?:_KEY)?|SUPABASE_SERVICE_ROLE(?:_KEY)?)\s*[:=]\s*\S+",
re.I,
),
"A Supabase service-role-style value is assigned in the mapped source.",
),
]
VITE_SOURCEMAP_RE = re.compile(
"sourcemap\\s*:\\s*(?:true|'inline'|\"inline\"|'hidden'|\"hidden\")",
re.I,
)
NEXT_SOURCEMAP_RE = re.compile(r"productionBrowserSourceMaps\s*:\s*true")
WEBPACK_DEVTOOL_RE = re.compile(
r"devtool\s*:\s*\S*source-map"
)
@dataclass
class Finding:
severity: str
code: str
path: str
message: str
detail: str = ""
def to_dict(self) -> dict[str, str]:
d = {
"severity": self.severity,
"code": self.code,
"path": self.path,
"message": self.message,
}
if self.detail:
d["detail"] = self.detail
return d
@dataclass
class Report:
root: Path
findings: list[Finding] = field(default_factory=list)
asset_files: int = 0
map_files: int = 0
mapping_urls: int = 0
configs: list[str] = field(default_factory=list)
def add(self, finding: Finding) -> None:
self.findings.append(finding)
@property
def errors(self) -> list[Finding]:
return [f for f in self.findings if f.severity == "error"]
@property
def warnings(self) -> list[Finding]:
return [f for f in self.findings if f.severity == "warning"]
def rel(root: Path, path: Path) -> str:
try:
return path.resolve().relative_to(root.resolve()).as_posix()
except ValueError:
return path.as_posix()
def iter_files(root: Path) -> Iterable[Path]:
for p in root.rglob("*"):
if not p.is_file():
continue
if any(part in SKIP_DIRS for part in p.parts):
continue
yield p
def read_text(path: Path) -> str | None:
try:
data = path.read_bytes()
except OSError:
return None
if b"\x00" in data[:1024]:
return None
if len(data) > 8_000_000:
data = data[:8_000_000]
for enc in ("utf-8", "utf-8-sig", "latin-1"):
try:
return data.decode(enc)
except UnicodeDecodeError:
continue
return None
def decode_data_url(url: str) -> str | None:
if not url.startswith("data:"):
return None
try:
header, _, payload = url.partition(",")
if not payload:
return None
if ";base64" in header.lower():
raw = base64.b64decode(payload, validate=False)
return raw.decode("utf-8", errors="replace")
return unquote(payload)
except (ValueError, UnicodeDecodeError):
return None
def parse_map_payload(text: str) -> dict[str, Any] | None:
text = text.strip()
if text.startswith(")]}'"):
text = text.split("\n", 1)[-1]
try:
data = json.loads(text)
except json.JSONDecodeError:
return None
if not isinstance(data, dict):
return None
return data
def collect_map_text(data: dict[str, Any]) -> tuple[str, list[tuple[str, str]]]:
sources = data.get("sources") or []
contents = data.get("sourcesContent") or []
names = data.get("names") or []
chunks: list[tuple[str, str]] = []
parts = [str(data.get("file") or "")]
if isinstance(names, list):
parts.extend(str(n) for n in names if n)
if isinstance(sources, list):
parts.extend(str(s) for s in sources if s)
for i, src in enumerate(sources):
body = ""
if isinstance(contents, list) and i < len(contents) and isinstance(contents[i], str):
body = contents[i]
chunks.append((str(src) if src else "source[%d]" % i, body))
if body:
parts.append(body)
elif isinstance(contents, list):
for i, body in enumerate(contents):
if isinstance(body, str):
chunks.append(("source[%d]" % i, body))
parts.append(body)
return "\n".join(parts), chunks
def extract_paths(text: str) -> list[str]:
found: list[str] = []
seen: set[str] = set()
for m in PATH_RE.finditer(text):
val = m.group(0)
if val not in seen:
seen.add(val)
found.append(val)
return found
def extract_routes(text: str) -> list[str]:
found: list[str] = []
seen: set[str] = set()
for rex in (HIDDEN_ROUTE_RE, PREVIEW_ROUTE_RE):
for m in rex.finditer(text):
val = m.group(0).rstrip('? ')
if val not in seen:
seen.add(val)
found.append(val)
return found
def extract_secrets(text: str) -> list[tuple[str, str]]:
hits: list[tuple[str, str]] = []
for code, rex, message in SECRET_RULES:
if rex.search(text):
hits.append((code, message))
return hits
def inspect_map(report: Report, path: Path, data: dict[str, Any], origin: str) -> None:
loc = rel(report.root, path)
sources = data.get("sources") if isinstance(data.get("sources"), list) else []
contents = data.get("sourcesContent") if isinstance(data.get("sourcesContent"), list) else []
has_content = any(isinstance(c, str) and c.strip() for c in contents)
source_count = len([s for s in sources if s])
if has_content:
n = sum(1 for c in contents if isinstance(c, str) and c.strip())
sample = []
for i, src in enumerate(sources):
if i < len(contents) and isinstance(contents[i], str) and contents[i].strip():
sample.append(str(src) or "source[%d]" % i)
if len(sample) >= 3:
break
extra = ", including %s" % ", ".join(sample) if sample else ""
report.add(
Finding(
"error",
"sources_content_shipped",
loc,
"The map embeds original source for %d file(s)%s." % (n, extra),
origin,
)
)
elif path.suffix == ".map":
count_label = str(source_count) if source_count else "its"
report.add(
Finding(
"error",
"map_file_present",
loc,
"A source map file is in the tree. Even without sourcesContent, "
"the map lists %s original path(s) and is fetchable if you deploy this folder."
% count_label,
origin,
)
)
blob, chunks = collect_map_text(data)
scanned = False
for name, body in chunks:
target = "\n".join(part for part in (name, body) if part)
if not target:
continue
scanned = True
label = "%s [%s]" % (loc, name) if name else loc
for code, message in extract_secrets(target):
report.add(Finding("error", code, label, message, origin))
for pth in extract_paths(target):
report.add(
Finding(
"warning",
"path_disclosure",
label,
"Mapped source discloses a local filesystem path: %s" % pth,
origin,
)
)
for route in extract_routes(body):
report.add(
Finding(
"warning",
"hidden_route_in_map",
label,
"Mapped source mentions an internal-looking route: %s" % route,
origin,
)
)
if not scanned:
for code, message in extract_secrets(blob):
report.add(Finding("error", code, loc, message, origin))
for pth in extract_paths(blob):
report.add(
Finding(
"warning",
"path_disclosure",
loc,
"Mapped source discloses a local filesystem path: %s" % pth,
origin,
)
)
for route in extract_routes(blob):
report.add(
Finding(
"warning",
"hidden_route_in_map",
loc,
"Mapped source mentions an internal-looking route: %s" % route,
origin,
)
)
def inspect_mapping_url(report: Report, path: Path, url: str) -> None:
loc = rel(report.root, path)
report.mapping_urls += 1
if url.startswith("data:"):
report.add(
Finding(
"error",
"inline_source_map",
loc,
"An inline (data-URI) source map is baked into this file.",
)
)
payload = decode_data_url(url)
if payload is None:
report.add(
Finding(
"warning",
"unreadable_inline_map",
loc,
"The inline source map could not be decoded.",
)
)
return
data = parse_map_payload(payload)
if data is None:
report.add(
Finding(
"warning",
"invalid_source_map",
loc,
"The inline source map is not valid JSON.",
)
)
return
inspect_map(report, path, data, origin="inline sourceMappingURL")
return
report.add(
Finding(
"error",
"source_mapping_url",
loc,
"This file points at a source map: %s" % url,
)
)
candidate = url.split("?", 1)[0]
if candidate.startswith("/") and not candidate.startswith("//"):
map_path = report.root / candidate.lstrip("/")
else:
map_path = path.parent / candidate
if map_path.is_file():
return
report.add(
Finding(
"warning",
"dangling_source_mapping_url",
loc,
"sourceMappingURL points at %s, but that map is not in this tree. "
"A CDN or an older deploy may still be serving it." % url,
)
)
def inspect_config(report: Report, path: Path, text: str) -> None:
loc = rel(report.root, path)
report.configs.append(loc)
name = path.name.lower()
if name.startswith("vite.config") or "vite" in name:
m = VITE_SOURCEMAP_RE.search(text)
if m:
value = m.group(0).lower()
if "hidden" in value:
report.add(
Finding(
"error",
"vite_hidden_sourcemap",
loc,
"build.sourcemap is 'hidden'. Vite still writes .map files; "
"it only omits the sourceMappingURL comment. If you deploy the "
"output folder, the maps stay public at predictable URLs.",
)
)
elif "inline" in value:
report.add(
Finding(
"error",
"vite_inline_sourcemap",
loc,
"build.sourcemap is 'inline'. Production bundles will embed maps.",
)
)
else:
report.add(
Finding(
"error",
"vite_production_sourcemap",
loc,
"build.sourcemap is true. A production build will emit .map files "
"and sourceMappingURL comments into the output folder.",
)
)
if name.startswith("next.config") or NEXT_SOURCEMAP_RE.search(text):
if NEXT_SOURCEMAP_RE.search(text):
report.add(
Finding(
"error",
"next_production_sourcemaps",
loc,
"productionBrowserSourceMaps is true. Next.js will ship browser maps "
"in the production build.",
)
)
if WEBPACK_DEVTOOL_RE.search(text):
report.add(
Finding(
"error",
"webpack_production_devtool",
loc,
"webpack devtool is set to a production source-map mode. The output will "
"include maps (hidden-source-map still writes the files).",
)
)
def scan(root: Path) -> Report:
report = Report(root=root)
for path in iter_files(root):
suffix = path.suffix.lower()
if suffix == ".map":
report.map_files += 1
text = read_text(path)
if text is None:
report.add(
Finding(
"warning",
"unreadable_source_map",
rel(root, path),
"The source map file could not be read as text.",
)
)
continue
data = parse_map_payload(text)
if data is None:
report.add(
Finding(
"warning",
"invalid_source_map",
rel(root, path),
"The source map file is not valid JSON.",
)
)
continue
inspect_map(report, path, data, origin="map file")
continue
if path.name in CONFIG_NAMES or path.name.lower() in CONFIG_NAMES:
text = read_text(path)
if text is not None:
inspect_config(report, path, text)
continue
if suffix not in ASSET_SUFFIXES:
continue
report.asset_files += 1
text = read_text(path)
if text is None:
continue
for m in SOURCEMAPPING_RE.finditer(text):
inspect_mapping_url(report, path, m.group(1))
return report
def format_report(report: Report) -> str:
lines: list[str] = []
lines.append("sourcemap_check.py (local files only)")
lines.append("root: %s" % report.root)
lines.append("")
lines.append("TREE")
lines.append(" js/css/html files %d" % report.asset_files)
lines.append(" source map files %d" % report.map_files)
lines.append(" sourceMappingURL %d" % report.mapping_urls)
if report.configs:
lines.append(" configs %d (%s)" % (len(report.configs), ", ".join(report.configs)))
else:
lines.append(" configs 0")
lines.append("")
lines.append("FINDINGS")
if not report.findings:
lines.append(" (none)")
else:
for item in report.findings:
lines.append("%-7s %-28s %s" % (item.severity.upper(), item.code, item.path))
wrapped = textwrap.fill(
item.message,
width=86,
initial_indent=" ",
subsequent_indent=" ",
)
lines.append(wrapped)
lines.append("")
n_err, n_warn = len(report.errors), len(report.warnings)
lines.append("VERDICT")
lines.append(" %d error(s), %d warning(s)" % (n_err, n_warn))
if n_err:
lines.append(" Do not ship this build. Source maps in the public folder expose original source.")
elif n_warn:
lines.append(" No errors, but the warnings are worth fixing before you deploy the folder.")
else:
lines.append(" No source-map findings on the local files.")
lines.append(" This is not a promise the live CDN has no leftover maps.")
return "\n".join(lines) + "\n"
def report_to_json(report: Report) -> dict[str, Any]:
return {
"root": str(report.root),
"asset_files": report.asset_files,
"map_files": report.map_files,
"source_mapping_urls": report.mapping_urls,
"configs": report.configs,
"errors": len(report.errors),
"warnings": len(report.warnings),
"findings": [item.to_dict() for item in report.findings],
}
MINIMAL_MAP = {
"version": 3,
"file": "index.js",
"sources": ["src/App.tsx"],
"sourcesContent": ["export const ok = true;\n"],
"names": [],
"mappings": "AAAA",
}
def _write(path: Path, text: str) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text, encoding="utf-8")
class SourceMapCheckTests(unittest.TestCase):
def setUp(self) -> None:
self.tmp = Path(tempfile.mkdtemp(prefix="sourcemap-check-"))
def tearDown(self) -> None:
shutil.rmtree(self.tmp, ignore_errors=True)
def codes(self, report: Report) -> list[str]:
return [item.code for item in report.findings]
def test_clean_tree_is_silent(self) -> None:
_write(self.tmp / "dist" / "assets" / "index.js", "console.log('ok');\n")
_write(
self.tmp / "vite.config.ts",
"import { defineConfig } from 'vite';\n"
"export default defineConfig({ build: { sourcemap: false } });\n",
)
report = scan(self.tmp)
self.assertEqual(report.findings, [])
def test_map_with_sources_content(self) -> None:
_write(self.tmp / "dist" / "index.js.map", json.dumps(MINIMAL_MAP))
report = scan(self.tmp)
self.assertIn("sources_content_shipped", self.codes(report))
self.assertTrue(any(item.severity == "error" for item in report.findings))
def test_map_without_sources_content_still_errors(self) -> None:
payload = {
"version": 3,
"file": "index.js",
"sources": ["src/App.tsx"],
"mappings": "AAAA",
}
_write(self.tmp / "dist" / "index.js.map", json.dumps(payload))
report = scan(self.tmp)
self.assertIn("map_file_present", self.codes(report))
def test_source_mapping_url_and_paired_map(self) -> None:
_write(
self.tmp / "dist" / "index.js",
"console.log(1);\n//# sourceMappingURL=index.js.map\n",
)
_write(self.tmp / "dist" / "index.js.map", json.dumps(MINIMAL_MAP))
report = scan(self.tmp)
self.assertIn("source_mapping_url", self.codes(report))
self.assertIn("sources_content_shipped", self.codes(report))
self.assertNotIn("dangling_source_mapping_url", self.codes(report))
def test_dangling_source_mapping_url(self) -> None:
_write(
self.tmp / "dist" / "index.js",
"console.log(1);\n//# sourceMappingURL=index.js.map\n",
)
report = scan(self.tmp)
self.assertIn("source_mapping_url", self.codes(report))
self.assertIn("dangling_source_mapping_url", self.codes(report))
def test_inline_data_uri_map(self) -> None:
raw = json.dumps(MINIMAL_MAP).encode("utf-8")
uri = "data:application/json;base64," + base64.b64encode(raw).decode("ascii")
_write(self.tmp / "dist" / "index.js", "console.log(1);\n//# sourceMappingURL=%s\n" % uri)
report = scan(self.tmp)
self.assertIn("inline_source_map", self.codes(report))
self.assertIn("sources_content_shipped", self.codes(report))
def test_secret_in_sources_content(self) -> None:
payload = {
"version": 3,
"file": "admin.js",
"sources": ["src/lib/admin.ts"],
"sourcesContent": [
'export const SUPABASE_SERVICE_ROLE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.fixture-not-real";\n'
],
"mappings": "AAAA",
}
_write(self.tmp / "dist" / "admin.js.map", json.dumps(payload))
report = scan(self.tmp)
self.assertIn("service_role_assign", self.codes(report))
def test_stripe_key_in_map(self) -> None:
payload = {
"version": 3,
"sources": ["src/pay.ts"],
"sourcesContent": ["const k = 'sk_test_51ABCDEFGHIJKLMNOPQRSTUV';\n"],
"mappings": "AAAA",
}
_write(self.tmp / "dist" / "pay.js.map", json.dumps(payload))
report = scan(self.tmp)
self.assertIn("stripe_secret", self.codes(report))
def test_path_disclosure(self) -> None:
payload = {
"version": 3,
"sources": ["/Users/mira/Projects/crowstep-site/src/App.tsx"],
"sourcesContent": ["export const ok = true;\n"],
"mappings": "AAAA",
}
_write(self.tmp / "dist" / "index.js.map", json.dumps(payload))
report = scan(self.tmp)
self.assertTrue(any(item.code == "path_disclosure" for item in report.findings))
def test_hidden_route_in_map(self) -> None:
payload = {
"version": 3,
"sources": ["src/pages/InternalQueue.tsx"],
"sourcesContent": ["export const path = '/internal/bindery-queue';\n"],
"mappings": "AAAA",
}
_write(self.tmp / "dist" / "index.js.map", json.dumps(payload))
report = scan(self.tmp)
self.assertTrue(any(item.code == "hidden_route_in_map" for item in report.findings))
def test_vite_sourcemap_true(self) -> None:
_write(
self.tmp / "vite.config.ts",
"export default { build: { sourcemap: true } };\n",
)
report = scan(self.tmp)
self.assertIn("vite_production_sourcemap", self.codes(report))
def test_vite_hidden_sourcemap(self) -> None:
_write(
self.tmp / "vite.config.ts",
"export default { build: { sourcemap: 'hidden' } };\n",
)
report = scan(self.tmp)
self.assertIn("vite_hidden_sourcemap", self.codes(report))
def test_next_production_browser_source_maps(self) -> None:
_write(
self.tmp / "next.config.js",
"module.exports = { productionBrowserSourceMaps: true };\n",
)
report = scan(self.tmp)
self.assertIn("next_production_sourcemaps", self.codes(report))
def test_webpack_devtool(self) -> None:
_write(
self.tmp / "webpack.config.js",
"module.exports = { devtool: 'hidden-source-map' };\n",
)
report = scan(self.tmp)
self.assertIn("webpack_production_devtool", self.codes(report))
def test_skips_node_modules(self) -> None:
_write(
self.tmp / "node_modules" / "pkg" / "index.js.map",
json.dumps(MINIMAL_MAP),
)
report = scan(self.tmp)
self.assertEqual(report.map_files, 0)
self.assertEqual(report.findings, [])
def test_css_source_mapping_comment(self) -> None:
_write(
self.tmp / "dist" / "index.css",
"body{color:#111}\n/*# sourceMappingURL=index.css.map */\n",
)
payload = {
"version": 3,
"file": "index.css",
"sources": ["src/styles.css"],
"sourcesContent": ["body { color: #111; }\n"],
"mappings": "AAAA",
}
_write(self.tmp / "dist" / "index.css.map", json.dumps(payload))
report = scan(self.tmp)
self.assertIn("source_mapping_url", self.codes(report))
self.assertIn("sources_content_shipped", self.codes(report))
def test_invalid_map_is_warning(self) -> None:
_write(self.tmp / "dist" / "index.js.map", "{not json")
report = scan(self.tmp)
self.assertIn("invalid_source_map", self.codes(report))
self.assertTrue(
all(item.severity == "warning" for item in report.findings if item.code == "invalid_source_map")
)
def test_json_output_shape(self) -> None:
_write(self.tmp / "dist" / "index.js.map", json.dumps(MINIMAL_MAP))
payload = report_to_json(scan(self.tmp))
self.assertIn("findings", payload)
self.assertGreaterEqual(payload["errors"], 1)
self.assertEqual(payload["map_files"], 1)
def run_self_test() -> int:
suite = unittest.defaultTestLoader.loadTestsFromTestCase(SourceMapCheckTests)
result = unittest.TextTestRunner(verbosity=2).run(suite)
return 0 if result.wasSuccessful() else 1
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(
description="Flag production source maps in a local build tree (no network)."
)
parser.add_argument("root", nargs="?", default=".", help="Project or dist directory to scan")
parser.add_argument("--json", action="store_true", help="Print JSON instead of text")
parser.add_argument("--self-test", action="store_true", help="Run the built-in tests")
args = parser.parse_args(argv)
if args.self_test:
return run_self_test()
root = Path(args.root).expanduser()
if not root.exists():
print("error: %s does not exist" % root, file=sys.stderr)
return 2
report = scan(root)
if args.json:
json.dump(report_to_json(report), sys.stdout, indent=2)
sys.stdout.write("\n")
else:
sys.stdout.write(format_report(report))
return 1 if report.errors else 0
if __name__ == "__main__":
sys.exit(main())
Run 1: the raw export
$ python3 sourcemap_check.py fixtures/before
sourcemap_check.py (local files only)
root: fixtures/before
TREE
js/css/html files 5
source map files 2
sourceMappingURL 2
configs 1 (vite.config.ts)
FINDINGS
ERROR vite_production_sourcemap vite.config.ts
build.sourcemap is true. A production build will emit .map files and
sourceMappingURL comments into the output folder.
ERROR source_mapping_url dist/assets/index-a8f3c1.css
This file points at a source map: index-a8f3c1.css.map
ERROR sources_content_shipped dist/assets/index-a8f3c1.css.map
The map embeds original source for 1 file(s), including
/Users/mira/Projects/crowstep-site/src/styles.css.
WARNING path_disclosure dist/assets/index-a8f3c1.css.map [/Users/mira/Projects/crowstep-site/src/styles.css]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/styles.css
ERROR sources_content_shipped dist/assets/index-a8f3c1.js.map
The map embeds original source for 3 file(s), including
/Users/mira/Projects/crowstep-site/src/App.tsx, /Users/mira/Projects/crowstep-
site/src/lib/admin.ts, /Users/mira/Projects/crowstep-
site/src/pages/InternalQueue.tsx.
WARNING path_disclosure dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/App.tsx]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/App.tsx
ERROR service_role_assign dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
A Supabase service-role-style value is assigned in the mapped source.
WARNING path_disclosure dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/lib/admin.ts
WARNING hidden_route_in_map dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
Mapped source mentions an internal-looking route: /internal/bindery-queue
WARNING hidden_route_in_map dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
Mapped source mentions an internal-looking route: /preview/invoice
WARNING path_disclosure dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/pages/InternalQueue.tsx]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/pages/InternalQueue.tsx
WARNING hidden_route_in_map dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/pages/InternalQueue.tsx]
Mapped source mentions an internal-looking route: /internal/bindery-queue
ERROR source_mapping_url dist/assets/index-a8f3c1.js
This file points at a source map: index-a8f3c1.js.map
VERDICT
6 error(s), 7 warning(s)
Do not ship this build. Source maps in the public folder expose original source.
Six errors and seven warnings on a folder that already looks like a production build. The maps do not just confirm that TypeScript was compiled. They hand over src/lib/admin.ts, a service-role assignment, the path /Users/mira/Projects/crowstep-site/..., and two routes that were never linked from the homepage.
Run 2: I only set sourcemap: 'hidden'
The mid tree is the tempting one-line fix. I changed vite.config.ts from sourcemap: true to sourcemap: 'hidden' and rebuilt the comment out of the JS and CSS. I did not delete the .map files. I did not take the service-role value out of the client source. I did not change the paths.
$ python3 sourcemap_check.py fixtures/mid
sourcemap_check.py (local files only)
root: fixtures/mid
TREE
js/css/html files 5
source map files 2
sourceMappingURL 0
configs 1 (vite.config.ts)
FINDINGS
ERROR vite_hidden_sourcemap vite.config.ts
build.sourcemap is 'hidden'. Vite still writes .map files; it only omits the
sourceMappingURL comment. If you deploy the output folder, the maps stay
public at predictable URLs.
ERROR sources_content_shipped dist/assets/index-a8f3c1.css.map
The map embeds original source for 1 file(s), including
/Users/mira/Projects/crowstep-site/src/styles.css.
WARNING path_disclosure dist/assets/index-a8f3c1.css.map [/Users/mira/Projects/crowstep-site/src/styles.css]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/styles.css
ERROR sources_content_shipped dist/assets/index-a8f3c1.js.map
The map embeds original source for 3 file(s), including
/Users/mira/Projects/crowstep-site/src/App.tsx, /Users/mira/Projects/crowstep-
site/src/lib/admin.ts, /Users/mira/Projects/crowstep-
site/src/pages/InternalQueue.tsx.
WARNING path_disclosure dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/App.tsx]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/App.tsx
ERROR service_role_assign dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
A Supabase service-role-style value is assigned in the mapped source.
WARNING path_disclosure dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/lib/admin.ts
WARNING hidden_route_in_map dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
Mapped source mentions an internal-looking route: /internal/bindery-queue
WARNING hidden_route_in_map dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/lib/admin.ts]
Mapped source mentions an internal-looking route: /preview/invoice
WARNING path_disclosure dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/pages/InternalQueue.tsx]
Mapped source discloses a local filesystem path:
/Users/mira/Projects/crowstep-site/src/pages/InternalQueue.tsx
WARNING hidden_route_in_map dist/assets/index-a8f3c1.js.map [/Users/mira/Projects/crowstep-site/src/pages/InternalQueue.tsx]
Mapped source mentions an internal-looking route: /internal/bindery-queue
VERDICT
4 error(s), 7 warning(s)
Do not ship this build. Source maps in the public folder expose original source.
Six errors down to four. The two sourceMappingURL findings went away, because hidden omits the comment. Everything else stayed: the map files, the embedded source, the service-role assignment, the local paths, and the internal routes. The config finding changed names, from vite_production_sourcemap to vite_hidden_sourcemap, which is the point. hidden is not a synonym for off.
This is why "I turned off the sourceMappingURL comment" is not a source-map fix. The files people tidy first are often not the ones a stranger will request.
Run 3: the maps are gone, and the config will not put them back
The after tree keeps the same public homepage. vite.config.ts now has sourcemap: false. There are no .map files in dist/. The JS and CSS no longer end with a sourceMappingURL comment. The internal queue module is not in the shipped tree.
$ python3 sourcemap_check.py fixtures/after
sourcemap_check.py (local files only)
root: fixtures/after
TREE
js/css/html files 5
source map files 0
sourceMappingURL 0
configs 1 (vite.config.ts)
FINDINGS
(none)
VERDICT
0 error(s), 0 warning(s)
No source-map findings on the local files.
This is not a promise the live CDN has no leftover maps.
Six errors down to zero. The last line is there on purpose. A clean tree means this checkout is not shipping maps. It does not mean Cloudflare, Netlify, or last week's Vercel deploy has already forgotten index-a8f3c1.js.map.
What the findings actually mean
A sourceMappingURL comment is a public pointer. It is how DevTools find the map, and it is how everyone else finds it too. An inline data-URI map is the same pointer, baked into the asset, so deleting a sibling .map file does nothing.
sourcesContent is the original source, not a hint about it. If the map lists src/lib/admin.ts and also embeds the file, you have published that file. Even without sourcesContent, the sources array still discloses paths. /Users/mira/Projects/crowstep-site/... is a username, a machine layout, and a repo name.
A service-role value in mapped client source is not "the map leaked a secret." The secret was already in the client bundle. The map just made it readable. The fix is to stop putting a service role in browser code, then stop shipping maps.
sourcemap: 'hidden' is the finding to stare at. It dropped two errors and left the rest. Vite's own docs describe the behavior: generate the maps, do not append the comment. That is useful when you want to upload maps to an error tracker and keep them off the public origin. It is not useful when the upload is "deploy the dist folder."
The same pattern shows up in other tools. Next.js productionBrowserSourceMaps: true ships browser maps in the production build. Webpack hidden-source-map still writes the files. Whether you asked Claude to build a website, or you clicked publish in a hosted builder, the question after the demo is the same: what else is in the folder you just deployed?
What I would do with a real vibe-coded marketing site
If I were handed a marketing site tomorrow, because a prompt produced a polished homepage or because I wanted the public folder to contain only what I meant to publish, I would do this before I pointed a domain at it:
- Run
python3 sourcemap_check.py .on the tree you are about to deploy, on a machine you own. - Set the production sourcemap flag to off:
build.sourcemap: falsein Vite,productionBrowserSourceMaps: false(or unset) in Next.js, nosource-mapdevtoolin a production webpack build. Do not substitute'hidden'unless you have a separate, private upload for those files. - Delete any
.mapfiles from the deploy directory. Confirm the JS and CSS no longer end withsourceMappingURL. - If the checker reported a secret in mapped source, treat that value as exposed. Rotate it, and move anything like a service role out of the client.
- After the next prompt "just adds a preview route," run the checker again. Maps come back when the config comes back.
A site built with an AI website builder still has to pass this test. Generating a homepage is the cheap part. Knowing whether the public folder also contains the original TypeScript — comments, secrets, hidden routes, and the path to a folder on your laptop — is the part that decides whether "we shipped the site" is the same as "we shipped the source."
What we do in PolyDraft, and what we do not claim
PolyDraft is the AI website builder we work on. We care about this because a site that looks finished in preview is still a liability if the published assets include a map of the source that built them. If you are choosing an AI website builder for a small business, the demo will not show you the dist folder. Ask what gets deployed, and whether source maps are part of that upload. We do not claim that every build we have ever shipped already passed a check like this, or that a clean local scan means an old CDN object is gone. We still run checks like these on what we ship, and you should run them on anything with your name on the domain, whoever or whatever built it.
Before you point the domain at it
- Search the production config for
sourcemap,source-map, andproductionBrowserSourceMaps. If the value istrue,'inline', or'hidden', you are not done. - List the deploy directory for
*.map. If a file is there, it will be fetchable if you upload the folder. - Open the bottom of a production JS or CSS file. If you see
sourceMappingURL, treat that as a public link. - Run
python3 sourcemap_check.py .against the files you are shipping. - Save the files and run the checker again after the next prompt turns maps back on to "help with debugging."
A vibe-coded site can be minified, pretty, and still a published copy of your source. Six errors on a finished-looking dist folder is not a linter being picky. It is the build telling anyone who asks how it was made.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.

