From 8717ac75935e727e7504b0933d94fbd2dafd0368 Mon Sep 17 00:00:00 2001 From: Torsten Date: Wed, 8 Feb 2023 15:38:00 +0200 Subject: [PATCH] fixed, opal helper was not loaded, why is wip --- Gemfile | 1 + Gemfile.lock | 1 + app/assets/config/manifest.js | 1 - app/assets/config/vue_r_manifest.js | 1 - lib/vue_r/engine.rb | 4 ---- .../{application.js.rb => dummy.js.rb} | 11 +++++++++- .../app/controllers/application_controller.rb | 1 + test/dummy/app/views/images/show.html.haml | 3 --- .../app/views/layouts/application.html.erb | 3 +-- test/dummy/config/initializers/opal.rb | 22 +++++++++++++++++++ 10 files changed, 36 insertions(+), 12 deletions(-) delete mode 100644 app/assets/config/manifest.js rename test/dummy/app/assets/javascript/{application.js.rb => dummy.js.rb} (65%) create mode 100644 test/dummy/config/initializers/opal.rb diff --git a/Gemfile b/Gemfile index 16b3544..25f22bf 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,7 @@ gem "puma" , "5.6.5" gem "haml-rails" gem "sqlite3" gem "active_hash" +gem "opal-rails" # Start debugger with binding.b [https://github.com/ruby/debug] # gem "debug", ">= 1.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index 2c3f15f..4490736 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -194,6 +194,7 @@ PLATFORMS DEPENDENCIES active_hash haml-rails + opal-rails puma (= 5.6.5) rails sprockets-rails diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js deleted file mode 100644 index 8716310..0000000 --- a/app/assets/config/manifest.js +++ /dev/null @@ -1 +0,0 @@ -//= link_tree ../javascript .js diff --git a/app/assets/config/vue_r_manifest.js b/app/assets/config/vue_r_manifest.js index b94f187..e549779 100644 --- a/app/assets/config/vue_r_manifest.js +++ b/app/assets/config/vue_r_manifest.js @@ -1,2 +1 @@ //= link_directory ../stylesheets/vue_r .css -//= link_tree ../../../opal .js diff --git a/lib/vue_r/engine.rb b/lib/vue_r/engine.rb index 7104cf6..07bcbdb 100644 --- a/lib/vue_r/engine.rb +++ b/lib/vue_r/engine.rb @@ -6,10 +6,6 @@ module VueR class Engine < ::Rails::Engine isolate_namespace VueR - initializer "vue_r.assets.precompile" do |app| - app.config.assets.precompile += %w( vue_r.js ) - end - end end diff --git a/test/dummy/app/assets/javascript/application.js.rb b/test/dummy/app/assets/javascript/dummy.js.rb similarity index 65% rename from test/dummy/app/assets/javascript/application.js.rb rename to test/dummy/app/assets/javascript/dummy.js.rb index 9c9be8a..9c71183 100644 --- a/test/dummy/app/assets/javascript/application.js.rb +++ b/test/dummy/app/assets/javascript/dummy.js.rb @@ -1,8 +1,17 @@ require "opal" +require "native" +require 'promise' +require 'opal-parser' +require 'browser/setup/mini' + + +require "vue_r/application" +require "vue_r/mounter" + +puts "hello world!" # Uncomment the following to print out you're hello-world with Opal: # -# puts "hello world!" # # The following will append a hello-world to your element: # diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index 09705d1..a68641e 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,2 +1,3 @@ class ApplicationController < ActionController::Base + helper OpalHelper end diff --git a/test/dummy/app/views/images/show.html.haml b/test/dummy/app/views/images/show.html.haml index 5dfe290..c127eb1 100644 --- a/test/dummy/app/views/images/show.html.haml +++ b/test/dummy/app/views/images/show.html.haml @@ -6,9 +6,6 @@ %a.underline{ e_click: "bg_change" , r_class: 'back'} {{ back }} :opal - puts "HI" - -:plain class Clicker < VueR::Application def bg_change self.state = !self.state diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index be462a1..aefcefd 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -7,8 +7,7 @@ <%= csp_meta_tag %> <%= stylesheet_link_tag "application" %> - <%= javascript_include_tag "vue_r" %> - <%= javascript_include_tag "application" %> + <%= javascript_include_tag "dummy" %> diff --git a/test/dummy/config/initializers/opal.rb b/test/dummy/config/initializers/opal.rb new file mode 100644 index 0000000..aaba247 --- /dev/null +++ b/test/dummy/config/initializers/opal.rb @@ -0,0 +1,22 @@ +# Check out the full list of the available configuration options at +# https://github.com/opal/opal/blob/master/lib/opal/config.rb + +Rails.application.configure do + # We suggest keeping the configuration above as default for all environments, + # disabling some of them might slightly reduce the bundle size or reduce performance + # by degrading some ruby features. + config.opal.method_missing_enabled = true + config.opal.const_missing_enabled = true + config.opal.arity_check_enabled = true + config.opal.freezing_stubs_enabled = true + config.opal.dynamic_require_severity = :ignore + + # To enable passing assigns from the controller to the opal template handler + # change the following configuration to one of these values: + # + # - true # both locals and instance variables + # - :locals # only locals + # - :ivars # only instance variables + # + config.opal.assigns_in_templates = false +end