Compiled JS output is imported differently depending on environment

#1

Hi, I’m looking at ember-elm (Elm to JS transpiler) and I’m facing an issue where the compiled code is imported differently in different environments.

The Elm compiler takes all .elm files and outputs one .js file. This file is then correctly picked up by broccoli build system. But the problem is how it is glued into the resulting bundle.

When imported in dummy app, it is wrapped in define fn.

define('dummy/elm-modules', ['export'], function(_export) {
  // export is defined!
});

but when imported in app, it is imported as

define('app-name/elm-modules', [], function() { 
//  note the missing export
})

and when imported without export default ... it doesn’t wrap it in define at all.

I’ve tried to write some hacky wrapper around it to outsmart that, but it’s not working.

What’s the best way to handle this so it works for addons, engines, dummy apps and also regular apps? Plus ideally caching works as well.

Thanks for your help.