Wednesday, 15 July 2015

ember.js - Ember CLI ES6 Modules: import path to app root -


When using AMRI CLI, the import path in ES6 modules is very confusing. For example, if I want to import a model deep in my application, then I end up doing something like this:

import from '' ../../ .. /../ ./models/user ';

This is a test of error and error, because it easily imagines how deep I am using it in the folder tree. Even worse, if I reorganize my files, everything is broken.

Therefore, I can use a complete path like this:

  'app-name / model / user' by user name;  

I do not like the app name on the hard-coded path, because it can change.

Is there any cloak to specify the application root?

./ does not work because ./ means the current path.

  Import user from './models/user'; Unfortunately for programming, there is no way to import at least ES6 in Amber, so you can. 'Do not use  ENV.modulePrefix . 

Although there is an alternative solution. Whenever you want to change the module prefix, then run the GNU sed command from ZSH inside the amber root. Previous>


No comments:

Post a Comment