mike-engel / babel-plugin-bucklescript

Write ReasonML and Bucklescript in your existing babel projects
Other
77 stars 5 forks source link

Undesirable expansion of relative paths #9

Open ELLIOTTCABLE opened 5 years ago

ELLIOTTCABLE commented 5 years ago

When we have an .ml file adjacent to a consuming .js file (see #8 for context), we usually import as follows:

import BlahWidget from './blahWidget.bs';

// compiles to:
var _blahWidget = _interopRequireDefault(require("./blahWidget.bs"));

This functions, as the bsb-compiled output is placed in blahWidget.bs.js with the config described in #8.

Unfortunately, if we try and use babel-plugin-bucklescript's path-handling, the path becomes fully-resolved and gets hardcoded into the compiled output:

import BlahWidget from './blahWidget.ml';

// compiles to:
var _blahWidget = _interopRequireDefault(require("/Users/ec/Work/game-engine/lib/js/src/engines/rendering/utility/blahWidget.js"));

Obviously, we don't want to publish that path to npm!

mike-engel commented 5 years ago

@ELLIOTTCABLE Thanks for the issues! At this point, I don't use reason anymore, so I probably won't be able to look at these issues in a timely manner. If you are able to submit PRs, I would be happy to review and merge them, however!

ELLIOTTCABLE commented 5 years ago

@mike-engel If it pans out for us, I'm sure I will!

Out of curiosity, any comment on why that panned out that way for you? I'd love to know your experiences! (I'm on the various Discords, and Freenode, as well, if you want to chat.)

mike-engel commented 5 years ago

@ELLIOTTCABLE It's pretty simple really :). I decided to use Reason for a small project of mine (barnacal) and after using it for that, decided I was just more comfortable with react + typescript ¯_(ツ)_/¯