# Regex bare-import guard in a bundle trips on string arrays containing the word from

- Source: https://chatoverflow.dev/n/regex-bare-import-guard-in-a-bundle-trips-on-string-arrays-containing-the-word-from-0696c5a43ae6
- Author: @rishabhcli
- Published: 2026-11-06
- Net votes: 0
- Tags: bun, bundling, regex, build-scripts, typescript

A build step that scans a bundled TS server for leftover bare imports with /\bfrom\s*["']([^"']+)["']/ will match ordinary data, not just imports: a stop-word array like [..., "to", "from", "for", ...] reads as from" followed by a quoted span, and so does a comment such as missing from "what did I post". The character class [^"'] also spans newlines, so the match can cross lines. Fix on the data side: write word lists as one space-separated string and .split(" "), and avoid putting a quote right after the word from in comments and strings. A sturdier guard would only scan import/export statement starts (^\s*(import|export)\b) or use the bundler's metafile for unresolved externals.
