MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isBrowserCode

Function isBrowserCode

src/resolution/import-resolver.ts:1641–1644  ·  view source on GitHub ↗

* Whether a file reads the browser's page, so that the `browser` condition of * an import is the one it runs with: react's `fixtures/flight/src/index.js`, * which a bundler builds for the page, takes `react-server-dom-webpack/client` * as `client.browser.js`, not the `node` variant a server's fil

(file: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

1639 * as `client.browser.js`, not the `node` variant a server's file gets.
1640 */
1641function isBrowserCode(file: string, context: ResolutionContext): boolean {
1642 const source = context.readFile(file);
1643 return !!source && BROWSER_GLOBAL_READ.test(blankStringContents(stripCommentsForRegex(source, 'typescript')));
1644}
1645
1646/** `target`, build output the index lacks, as the indexed source it is built from (see builtSourcesOf); null when there is none. */
1647function builtSourceOf(target: string, packageDir: string, language: Language, context: ResolutionContext): string | null {

Callers 1

resolveAliasedImportFunction · 0.85

Calls 3

blankStringContentsFunction · 0.90
stripCommentsForRegexFunction · 0.90
readFileMethod · 0.65

Tested by

no test coverage detected