Use the relative path for precompiled moduleName#13
Use the relative path for precompiled moduleName#13asakusuma wants to merge 3 commits intoemberjs:mainfrom
Conversation
|
@ef4 friendly reminder to take a look at this PR when you get a chance |
|
@ef4 bump 😃 |
|
Sorry, I wrote up a reply last time you pinged me but somehow it never submitted. First: I think it's dubious that we keep
I think the older behavior was not relative, it was a different, third thing: it was the notional "runtime" module name, which is neither a true absolute filename nor a relative filename. The problem is, in general that thing is hard to reverse engineer from a true on disk filename. However... This code can't actually assume that the So I don't think this PR is safe as is. Possible paths forward:
Finally, the core implementation in |
|
Addendum: it's really the ember template compiler that chooses to emit |
|
No worries, thanks for the explanation. So we actually do need the old behavior, whatever that may be, for a legacy internal addon that we are in the process of replacing. I agree that long term it would be good to get rid of I'll do some spelunking to try and reverse engineer the old behavior, I'm all ears if you have any insight on the correct way to do this. |
While testing out ember-cli/ember-cli-htmlbars#762, I realized that we probably don't want the precompiled template
moduleNameto be an absolute path, as that would be exposing production box internals. It also doesn't match the previous behavior of older templates wheremoduleNameis relative.This change constructs the
moduleNameusing thepath.relativeof the babelcwdandfilenameoptions, instead of justfilename. I tested this change out locally in an ember app. Instead of usingcwdandfilenamewithpath.relative, we could also usestate.file.opts.sourceFileName, which works here when I run locally, but not sure it would work universally. In theory, we could usefilenameRelative, but anecdotally that option is not available when I build my own app locally, so it may be a new option.Without the source code change, verified tests fail: