Shaun Chyxion
Shaun Chyxion

Reputation: 11

How to compile public es6 sources by Ember CLI

I have a JavaScript source file in folder public/assets/js/foo.js, it uses es6 syntax, the app works on debug mode, but when I try to build a production package, it failed because of es6 syntax error. My question is how could I compile public es6 JavaScript source by ember-cli, thanks for reply.

Upvotes: 1

Views: 186

Answers (1)

Lux
Lux

Reputation: 18240

Since the file is in /public I assume you have a <script> tag to import it?

You can transpile the files in /public, but a better way to go would be to place your file under /app, probably /app/utils and then import it like that:

import '/my-app/utils/my-file.js';

You can import the file for example in your app.js. This will include the file in your main build pipeline so it will get transpired and injected into your main my-app.js file.


The other way is to manually transpile it with your broccoli build pipeline. Check out broccoli-babel-transpiler.

Upvotes: 1

Related Questions