Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Importing Modules#52

Unanswered
troyam asked this question inQ&A
Feb 23, 2020· 1 comment
Discussion options

Sorry, I'm learning Ruby and I'm trying to use your module to convert to js.
The conversion works fine with filter --strict.

First case:

I'm trying to convert some files and I'm getting the code looks:

require(File.expand_path("../boot", __FILE__));

File now is a function and I'm getting"File is not defined";

My question is how to load submodules( in ruby ) of these .rb codes...

Can you explain to me please? Thanks!

You must be logged in to vote

Replies: 1 comment

Comment options

The answer would depend on your use case.

  1. Are you trying to get an existing code base to run pretty much as is in the context of a browser or some JavaScript environment? If so, you might want to look intoopal instead.
  2. Are you trying to migrate your code from Ruby to JavaScript? If so, be aware that JavaScript doesn't have exact equivalents to everything that Ruby has, so at best the conversion will be 80 to 95% successful. The statement above likely would map to animport statement, or perhaps a CJS require, but will require some manual editing to complete. Additionally, JavaScript has no native equivalent toFile.expand_path, the closest it has ispath.resolve which is roughly equivalent to Ruby'sFile.absolute_path.
  3. Are you trying to make use of an platform API that typically is only made available in JavaScript but you want to leverage your existing skills in Ruby? This use case differs significantly from the previous two in that you generally aren't starting with an existing code base.
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@troyam@rubys
Converted from issue

This discussion was converted from issue #52 on December 11, 2020 18:02.


[8]ページ先頭

©2009-2025 Movatter.jp