babel-plugin-reactylon 1.2.0-aplpha.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ParserUtils.js +5 -27
- package/package.json +1 -1
package/build/ParserUtils.js
CHANGED
|
@@ -90,39 +90,17 @@ class ParserUtils {
|
|
|
90
90
|
* @returns an object containing the discovered exports and side effects maps
|
|
91
91
|
*/
|
|
92
92
|
static generateExportsAndSideEffects(moduleName) {
|
|
93
|
-
const
|
|
93
|
+
const resolveFrom = process.cwd();
|
|
94
|
+
const requireFromCaller = createRequire(path.join(resolveFrom, 'package.json'));
|
|
94
95
|
let pkgJsonPath;
|
|
95
96
|
try {
|
|
96
|
-
pkgJsonPath =
|
|
97
|
+
pkgJsonPath = requireFromCaller.resolve(`${moduleName}/package.json`);
|
|
97
98
|
}
|
|
98
99
|
catch (_a) {
|
|
99
|
-
console.error(`The module "${moduleName}" doesn't exist or cannot be resolved.`);
|
|
100
|
+
console.error(`The module "${moduleName}" doesn't exist or cannot be resolved from ${resolveFrom}.`);
|
|
100
101
|
return { exports: {}, sideEffects: {} };
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
const pkgDir = path.dirname(pkgJsonPath); // non realpath qui
|
|
104
|
-
const isSymlink = (() => {
|
|
105
|
-
try {
|
|
106
|
-
return fs.lstatSync(pkgDir).isSymbolicLink();
|
|
107
|
-
}
|
|
108
|
-
catch (_a) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
})();
|
|
112
|
-
const realRoot = fs.realpathSync(pkgDir);
|
|
113
|
-
let modulePath = realRoot;
|
|
114
|
-
console.log(isSymlink, modulePath, realRoot);
|
|
115
|
-
if (isSymlink) {
|
|
116
|
-
const distPath = path.join(realRoot, 'dist');
|
|
117
|
-
if (fs.existsSync(distPath)) {
|
|
118
|
-
modulePath = distPath;
|
|
119
|
-
// opzionale: log utile in dev
|
|
120
|
-
console.warn(`[ParserUtils] ${moduleName} symlink rilevato → uso ${distPath}`);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
console.warn(`[ParserUtils] ${moduleName} symlink rilevato ma dist mancante → fallback a ${realRoot}`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
103
|
+
const modulePath = fs.realpathSync(path.dirname(pkgJsonPath));
|
|
126
104
|
const exportsMap = {};
|
|
127
105
|
const sideEffectsMap = {};
|
|
128
106
|
this.scanDirectory(modulePath, exportsMap, sideEffectsMap, modulePath, moduleName);
|
package/package.json
CHANGED