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

Function isBrowserCode

src/resolution/import-resolver.ts:1578–1581  ·  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

1576 * as `client.browser.js`, not the `node` variant a server's file gets.
1577 */
1578function isBrowserCode(file: string, context: ResolutionContext): boolean {
1579 const source = context.readFile(file);
1580 return !!source && BROWSER_GLOBAL_READ.test(blankStringContents(stripCommentsForRegex(source, 'typescript')));
1581}
1582
1583/** `target`, build output the index lacks, as the indexed source it is built from (see builtSourcesOf); null when there is none. */
1584function 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.80

Tested by

no test coverage detected