-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Yarn workspaces? #568
Comments
Not sure if anyone cares 4 years later but here's what we did in our fork of ember-cli-rails to get workspaces working: diff --git a/lib/ember_cli/path_set.rb b/lib/ember_cli/path_set.rb
index 9a30e2c..c246a51 100644
--- a/lib/ember_cli/path_set.rb
+++ b/lib/ember_cli/path_set.rb
@@ -1,3 +1,4 @@
+require "json"
require "ember_cli/helpers"
module EmberCli
@@ -41,7 +42,7 @@ module EmberCli
def ember
@ember ||= begin
- root.join("node_modules", "ember-cli", "bin", "ember").tap do |path|
+ ember_path.tap do |path|
unless path.executable?
fail DependencyError.new <<-MSG.strip_heredoc
No `ember-cli` executable found for `#{app_name}`.
@@ -148,6 +149,31 @@ module EmberCli
app_options[:yarn] || app_options[:yarn_path]
end
+ def workspace?
+ manifest_path = rails_root.join("package.json")
+ return false unless File.file?(manifest_path)
+
+ workspaces = JSON.parse(File.read(manifest_path)).fetch("workspaces", [])
+
+ workspaces.any? { |workspace| File.fnmatch(workspace, relative_path) }
+ end
+
+ def relative_path
+ @relative_path ||= begin
+ path = app_options.fetch(:path) { default_root }
+ pathname = Pathname.new(path)
+ pathname.relative_path_from(rails_root)
+ end
+ end
+
+ def ember_path
+ if workspace?
+ root.join("node_modules", ".bin", "ember")
+ else
+ root.join("node_modules", "ember-cli", "bin", "ember")
+ end
+ end
+
def app_name
app.name
end This works because doing a I am not confident in making a PR because I'm not totally 100% knowledgeable about this gem and not sure where setup from our app starts and the gem finish. It's also only been tested with yarn (latest), node 14, rails 5, and ruby 2.5. So YMMV. |
Which operating system and version is the project developed on?
macOS High Sierra, 10.13.4
Which version of
ruby
is the project developed on?2.3.1
Which version of
npm
is the project developed on?Yarn 1.6.0
Which version of
ember-cli
is the project developed on?3.1.3
What is the
rails
version?4.2.7.1
What is the
ember-cli-rails
version (fromGemfile
)?0.10.0
What is the
ember-cli-rails-addon
version (frompackage.json
)?0.10.0
Is your application server multi-threaded
(such as
puma
andunicorn
) or is it multi-process (such as thin and webrick)?Multi-threaded (
puma
).What are the contents of
config/initializers/ember.rb
?I'm using Yarn workspaces, and so I have the Rails project, a
frontend
directory inside it, and then the Ember app I want to mount lives atfrontend/packages/application
. However, I've been getting aDependencyError
:Due the nature of Yarn workspaces, the
node_modules
live infrontend
, not the application directory, but I think the application should still have access to the Ember CLI executable:Does the project support Yarn workspaces in general? If not, is that on the roadmap at all?
Thanks!
The text was updated successfully, but these errors were encountered: