Open dusura opened 7 years ago
Thanks for the PR @dusura !
Can you give me a little more background here -- an example of a file layout that current builder can't handle would be a great accelerator for me to wrap my head around the problem we're solving here...
Hi @ryan-roemer. Thanks for the interest. I created a small demo so you can understand the issue.
Thanks for the repository!
So everything works when I do:
npm install
npm run create-component
npm run bootstrap
cd component/YOUR-COMPONENT-HERE
npm install # <== I ADDED THIS
npm run figlet
[builder:config:environment] {"cwd":"/Users/rye/scm/vendor/builder-shared-dependencies-pr145/component/whiz-bang","dir":"/Users/rye/scm/vendor/builder-shared-dependencies-pr145/component/whiz-bang/node_modules/builder/lib"}
[builder:builder-core:start:91603] Started: run figlet
[builder:run] figlet - builder run figlet-cmd
[builder:proc:start] Command: builder run figlet-cmd
[builder:config:environment] {"cwd":"/Users/rye/scm/vendor/builder-shared-dependencies-pr145/component/whiz-bang","dir":"/Users/rye/scm/vendor/builder-shared-dependencies-pr145/component/whiz-bang/node_modules/builder/lib"}
[builder:builder-core:start:91604] Started: run figlet-cmd
[builder:run] figlet-cmd - figlet "my builder script!"
[builder:proc:start] Command: figlet "my builder script!"
_ _ _ _ _ _ _
_ __ ___ _ _ | |__ _ _(_) | __| | ___ _ __ ___ ___ _ __(_)_ __ | |_| |
| '_ ` _ \| | | | | '_ \| | | | | |/ _` |/ _ \ '__| / __|/ __| '__| | '_ \| __| |
| | | | | | |_| | | |_) | |_| | | | (_| | __/ | \__ \ (__| | | | |_) | |_|_|
|_| |_| |_|\__, | |_.__/ \__,_|_|_|\__,_|\___|_| |___/\___|_| |_| .__/ \__(_)
|___/ |_|
[builder:proc:end:0] Command: figlet "my builder script!"
[builder:builder-core:end:91604] Task: run figlet-cmd ended normally
[builder:proc:end:0] Command: builder run figlet-cmd
[builder:builder-core:end:91603] Task: run figlet ended normally
So you're saying that normally I should be able to not add that extra npm install
and still have everything work using npm
CLI? I can't see how that would work as even builder
isn't available in component/NAME_HERE/node_modules/.bin/builder
-- it seems maybe there's an install step or maybe a "use a wrapper command to execute provided by lerna
or something"?
(Separately, we have a tool to do just that -- exec commands with extra NODE_PATH
to deal with non-standard installations / requires, but I'll wait on chatting more about that until if/when I'm sure it would be appropriate to discuss here).
Interesting! I would've ran into this eventually, as I'm looking to start using builder in a monorepo. Related issue: https://github.com/FormidableLabs/builder/issues/150
Perhaps this is against the general philosophy of builder but it would be nice if builder could resolve "shared" dependencies by adding any local "node_modules" folders to its path.
For example, builder will not run commands in a monorepo that uses the lerna hoist feature because it doesn't know about the monorepo's base "node_modules".