whitefusionhq / rb2js-loader

Uses Ruby2JS to convert .js.rb files into .js files for Webpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Automatically add named exports

buhrmi opened this issue · comments

Hello,

my main use case for rb2js is to share code between server and client. The issue I'm facing is that in order to use a class/module compiled through rb2js-loader, I have to explicitly export that class/module. That obviously prevents me from using that file server-side.

My idea is to add a configuration option to instruct rb2js-loader to automatically export classes/modules. For example, a file bla.js.rb with the contents

module Shared
  def something
  end
end

would automatically export the module Shared and make it importable via import { Shared } from 'bla.js.rb'

We're starting to investigate some sort of system of auto-import to smooth out some of these edges, and I agree auto-export would be great as well.