0
votes

We're trying to migrate our legacy project to Ember CLI/Ember App Kit structures using ES6 modules, but we have some legacy Coffeescript files that need to be run outside the Ember App context. We're attempting to include the Coffeescript files in the Broccoli asset pipeline by using the 'ember-cli-coffeescript' Ember plugin/npm module.

The extra coffeescripts only seem to compile if we add the a line to the bottom of each file specifying as ES6 modules them like so:

`export default ModuleVariable`

This line adds them to the rest of the transpiled Ember code and without it the Coffeescript does not seem to be compiled at all. This would normally be fine, but adding this line also wraps them in AMD style modules, as one might expect. Is there any way to export them outside of an AMD module using the Ember-CLI so the code will run when immediately after the browser loads it?

1

1 Answers

0
votes

It seems the best way to handle this in the Ember-CLI convention is use the ES6 Module export code above and to add another line in the index.html that requires the ES6 Module using traditional AMD syntax like:

window.ModuleVariable = require('my-ember-app/module-variable')['default']