babel/karma-babel-preprocessor

module ids for systemjs including whole user path

jonricaurte opened this issue · 3 comments

Hi,

Below is part of my karma config:

preprocessors: {
  '**/*.slim': ['slim', 'ng-html2js'],
  '**/*.es6': ['babel']

},

babelPreprocessor: {
  options: {
    modules: 'system',
    moduleIds: true
  },
  filename: function(file) {
    return file.originalPath.replace(/\.es6$/, '.js');
  },
  sourceRoot: function(file) {
    return 'app/';
  }
},

When my code loads, the System.register is not using relative paths of where the file is, but is using the absolute path on the file system. My module ids are System.register("/Users/MyName/Code/myApp/app/assets/javascripts/app/top...")

However, I just want it to be from: System.register("app/top...")

I tried using the babel options (including sourceRoot) but now it shows like:
System.register("app//Users/MyName/Code/myApp/app/assets/javascripts/app/top...")

Thanks.

What if you specify an absolute path for sourceRoot?

it adds the following:

System.register("/app//...")

A workaround I did was this:

  filename: function(file) {
    return file.originalPath.replace(/.*?javascripts\//, '').replace(/\.es6$/, '.js');
  }

I meant an absolute path on the file system instead of on the browser.
On Wed, Apr 15, 2015 at 9:56 AM Jonathon Ricaurte notifications@github.com
wrote:

it adds the following:

System.register("/app//...")

A workaround I did was this:

filename: function(file) {
return file.originalPath.replace(/.*?javascripts//, '').replace(/.es6$/, '.js');
}


Reply to this email directly or view it on GitHub
#9 (comment)
.