MCPcopy Create free account
hub / github.com/adobe/react-spectrum / resolve

Function resolve

packages/dev/parcel-resolver-docs/DocsResolver.js:27–91  ·  view source on GitHub ↗
({dependency, options, specifier, config: resolver})

Source from the content-addressed store, hash-verified

25 });
26 },
27 async resolve({dependency, options, specifier, config: resolver}) {
28 if (
29 dependency.specifier.startsWith('docs:') ||
30 dependency.specifier.startsWith('apiCheck:') ||
31 dependency.pipeline === 'docs' ||
32 dependency.pipeline === 'docs-json' ||
33 dependency.pipeline === 'apiCheck'
34 ) {
35 let resolved = await resolver.resolve({
36 filename: specifier,
37 specifierType: dependency.specifierType,
38 parent: dependency.resolveFrom,
39 env: dependency.env,
40 sourcePath: dependency.sourcePath,
41 packageConditions: ['source', 'types']
42 });
43
44 if (resolved && resolved.filePath) {
45 // HACK: ensure source code is used to build types, not compiled code.
46 // Parcel removes the source field from package.json when the code comes from node_modules.
47 // these are full filepaths, so don't check if they start with the pattern, they won't
48 if (
49 (/@(react-spectrum|react-aria|react-stately|internationalized|spectrum-icons|adobe\/react-spectrum)/g.test(
50 resolved.filePath
51 ) ||
52 /react-aria-components/g.test(resolved.filePath)) &&
53 resolved.filePath.endsWith('.d.ts')
54 ) {
55 resolved.filePath = path.resolve(
56 path.dirname(resolved.filePath),
57 '..',
58 'src',
59 'index.ts'
60 );
61 }
62
63 resolved.filePath = await options.inputFS.realpath(resolved.filePath);
64 resolved.sideEffects = true;
65 return resolved;
66 }
67 }
68
69 if (
70 /^(@(react-spectrum|react-aria)\/(.*?)|react-aria-components)\/docs\/(.*)$/.test(specifier)
71 ) {
72 let baseDir = process.env.DOCS_ENV === 'production' ? 'docs' : 'packages';
73 return {filePath: path.join(options.projectRoot, baseDir, specifier)};
74 }
75
76 if (
77 /^((@(react-spectrum|react-aria|react-stately|internationalized|spectrum-icons|adobe\/react-spectrum))|react-aria-components|react-aria|react-stately)\/.*package.json$/.test(
78 specifier
79 )
80 ) {
81 let resolved = await resolver.resolve({
82 filename: specifier,
83 specifierType: dependency.specifierType,
84 parent: dependency.resolveFrom,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected