| 919 | } |
| 920 | |
| 921 | function createPublicExports(file, monopackage, scope, pkg) { |
| 922 | if (!importMap[monopackage]) { |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | let content = fs.readFileSync(file, 'utf8'); |
| 927 | let ast = recast.parse(content, { |
| 928 | parser: { |
| 929 | parse() { |
| 930 | return parse(content, { |
| 931 | sourceType: 'module', |
| 932 | plugins: ['typescript', 'jsx', 'importAttributes'], |
| 933 | sourceFilename: file, |
| 934 | tokens: true, |
| 935 | errorRecovery: true |
| 936 | }); |
| 937 | } |
| 938 | } |
| 939 | }); |
| 940 | |
| 941 | let groups = {}; |
| 942 | let unmatched = []; |
| 943 | let specifiers = []; |
| 944 | let typeSpecifiers = []; |
| 945 | for (let node of ast.program.body) { |
| 946 | if (node.type === 'ExportNamedDeclaration' && node.source) { |
| 947 | if (node.source.value.startsWith('./')) { |
| 948 | if (node.exportKind === 'type') { |
| 949 | typeSpecifiers.push(...node.specifiers); |
| 950 | } else { |
| 951 | specifiers.push(...node.specifiers); |
| 952 | } |
| 953 | } else { |
| 954 | unmatched.push(node); |
| 955 | } |
| 956 | |
| 957 | node.specifiers = node.specifiers.filter(s => { |
| 958 | if (s.exported.name === 'theme') { |
| 959 | s.exported = s.local; |
| 960 | return true; |
| 961 | } |
| 962 | return importMap[monopackage][s.exported.name]; |
| 963 | }); |
| 964 | if (node.source.value.startsWith('./') && node.specifiers.length > 0) { |
| 965 | let source = node.source.value.slice(2); |
| 966 | node.source.value = pkg ? `../src/${pkg}/${source}` : `../src/${source}`; |
| 967 | if ( |
| 968 | standalone.has(source) || |
| 969 | (monopackage === 'react-aria-components' && source === 'utils') |
| 970 | ) { |
| 971 | groups[source] ||= []; |
| 972 | groups[source].push(node); |
| 973 | } else if (parentFile[source]) { |
| 974 | groups[parentFile[source]] ||= []; |
| 975 | groups[parentFile[source]].push(node); |
| 976 | } |
| 977 | } |
| 978 | } |