-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
If I install asbundle globally (at ~/.local/lib/node_modules/asbundle and ~/.local/bin/asbundle),
and try to execute it in another project ~/my-prj, the module in ~/my-prj/node_modules would fail to resolve.
I read the code and maybe follow patch can fix this issue:
diff --git a/index.js b/index.js
index ef383dc..5eba5b1 100644
--- a/index.js
+++ b/index.js
@@ -134,7 +134,7 @@ const parse = (options, base, file, cache, modules) => {
}
} else if (!/^[A-Z]/.test(module.value)) {
process.chdir(base);
- const name = require.resolve(module.value);
+ const name = require.resolve(module.value, {paths: ['.']});
if (name !== module.value) addChunk(module, name);
else if (!CGJS) throw `unable to find "${name}" via file://${file}\n`;
}asbundle change the dir, but the node.js resolve path relative to the original file path,
so we have to add the new path to the resolve option.
I am not sure this is correct or best practice; I have never deal with the require path resolution api before.
Metadata
Metadata
Assignees
Labels
No labels