babel/karma-babel-preprocessor

With to5Options.moduleIds: true module names include whole path

johlrich opened this issue · 7 comments

With to5Options.moduleIds: true module names are including the entire path. I tried setting the sourceRoot, but then the path was duplicated before the desired module portion.

The only way I was able to get just the module portion was to add filenameRelative to the per file options and assign it a function to strip the initial path. I feel like I'm missing something simple over this being a bug. Thoughts?

Not sure if this matters, but I am on windows.

Actually a bug with 6to5, can you report it on the main repo? Thanks!

Actually, it's not really a bug. Can you provide the sourceRoot you're using? I likely know the issue.

With no option set i get the full path like C:/Dev/bitbucket/ng-devenv/workform/workform.spec

With option set to process.cwd() (which returns C:/Dev/bitbucket/ng-devenv) i get C:/Dev/bitbucket/ng-devenv/C:/Dev/bitbucket/ng-devenv/workform/workform.spec

You're too fast, commits before I can reply. I'll try this out and report back

@johlrich It'd be because internally the filename is normalised to unix path separators. So C:\foo\test.js is turned into c:/foo/test.js, this just makes path handling a lot more easier.

You'd be passing it a sourceRoot that uses \ instead of /. I just pushed a patch that will also normalise sourceRoot in the same way.

Behavior with the sourceRoot set to process.cwd() now sets the moduleid to C:/Dev/bitbucket/ng-devenv//workform/workform.spec

Haven't dug around yet to see what may be off

Huh, weird. It possibly has something to do with Windows path separators. Thought that patch might have fixed it. Can you reopen this in the main repo? I'll have a look in the morning.