@@ -20,3 +20,87 @@ index eed8109..4b422fa 100644
2020- presets: ["module:metro-react-native-babel-preset"]
2121+ presets: ["module:@react-native/babel-preset"]
2222 });
23+ diff --git a/configs/rollup-plugin-collect-dependencies.mjs b/configs/rollup-plugin-collect-dependencies.mjs
24+ index 2d0b5bfac7f1a1482bc1a222cba3e52b0339cc79..44ab7f4aa30abc0ba52672ea3e717f4401d00ed5 100644
25+ --- a/configs/rollup-plugin-collect-dependencies.mjs
26+ +++ b/configs/rollup-plugin-collect-dependencies.mjs
27+ @@ -2,9 +2,8 @@
28+
29+ import fg from "fast-glob";
30+ import fsExtra from "fs-extra";
31+ - import { existsSync, readFileSync, writeFileSync } from "fs";
32+ + import { existsSync, readFileSync, writeFileSync, cpSync } from "fs";
33+ import { dirname, join, parse } from "path";
34+ - import copy from "recursive-copy";
35+ import { promisify } from "util";
36+ import resolve from "resolve";
37+ import _ from "lodash";
38+ @@ -32,6 +31,7 @@ export function collectDependencies({
39+ managedDependencies.length = 0;
40+ },
41+ async resolveId(source, importer) {
42+ +
43+ // eslint-disable-next-line no-control-regex
44+ const sourceCleanedNullChar = source.replace(/\x00/g, "");
45+ if (sourceCleanedNullChar.startsWith(".") || sourceCleanedNullChar.startsWith("/")) {
46+ @@ -42,6 +42,8 @@ export function collectDependencies({
47+ dirname(importer ? importer : rollupOptions.input[0])
48+ );
49+
50+ +
51+ +
52+ if (resolvedPackagePath) {
53+ const isNotOnlyNativeOrHasNativeCode = !onlyNative || (await hasNativeCode(resolvedPackagePath));
54+ if (isNotOnlyNativeOrHasNativeCode && !managedDependencies.includes(resolvedPackagePath)) {
55+ @@ -58,6 +60,7 @@ export function collectDependencies({
56+ if (!licenseOptions) {
57+ return;
58+ }
59+ +
60+ for (const dependency of dependencies) {
61+ const packageJson = await scanDependency(dependency.packagePath);
62+ if (packageJson) {
63+ @@ -171,15 +174,34 @@ async function copyJsModule(moduleSourcePath, to) {
64+ if (existsSync(to)) {
65+ return;
66+ }
67+ - return promisify(copy)(moduleSourcePath, to, {
68+ - filter: [
69+ - "**/*.*",
70+ - LICENSE_GLOB,
71+ - "!**/{android,ios,windows,mac,jest,github,gradle,__*__,docs,jest,example*}/**/*",
72+ - "!**/*.{config,setup}.*",
73+ - "!**/*.{podspec,flow}"
74+ - ]
75+ - });
76+ +
77+ + try {
78+ + cpSync(moduleSourcePath, to, {
79+ + recursive: true,
80+ + filter: (src, dest) => {
81+ + const relativePath = src.replace(moduleSourcePath, '').replace(/^[\\/]/, '');
82+ +
83+ + // Skip certain directories
84+ + if (relativePath.match(/[\\/](android|ios|windows|mac|jest|github|gradle|__.*__|docs|example.*)[\\/]/)) {
85+ + return false;
86+ + }
87+ +
88+ + // Skip certain file types
89+ + if (relativePath.match(/\.(config|setup)\.|\.podspec$|\.flow$/)) {
90+ + return false;
91+ + }
92+ +
93+ + // Include LICENSE files
94+ + if (relativePath.match(/license/i)) {
95+ + return true;
96+ + }
97+ +
98+ + return true;
99+ + }
100+ + });
101+ + } catch (error) {
102+ + throw error;
103+ + }
104+ }
105+
106+ function getModuleName(modulePath) {
0 commit comments