cli
cli copied to clipboard
Setting "paths.root" to actual root directory leads to fatal results (detailed cause included)
I'm submitting a bug report
-
Library Version: aurelia-cli 0.18.0
-
Operating System: Windows Server 2012 R2 Datacenter
-
Node Version: 6.1.0
-
NPM Version: 3.8.6
-
Browser: all (this issue is not browser-related)
-
Language: ESNext
-
Current behavior: Change
paths.root
configuration inaurelia.json
to the actual root directory instead ofsrc
. When runningau build
, this will lead to aurelia-cli looks for node_modules dependencies in your codes in the parent directory of the actual root directory instead in the actual root directory. -
Expected/desired behavior: aurelia-cli should allow
paths.root
to be set to the actual root directory of the project without behaving errantly while bundling. -
Verbose explanation of cause per self-investigation:
When the bundling process comes to the
normalizePath()
function inLoader.js
, thefilePath
parameter turns out to be the result ofpaths.root
+../node_modules/some-package
, and the final version beacutal root
+paths.root
+../node_modules/some-package
given the codefilePath = path.join(rootDir, filePath)
. This is no problem ifpaths.root
is set to any sub-directory of the actual root, but if it is not, the final path would beactual root
+../node_modules/some-package
, which is a wrong path. Unfortunately, trying to bypass this behavior by manually declaring the package path tonode_modules/some-package
inaurelia-json
causes another equally severe problem. When bundling, the result of functiongetPackageFolder()
inpackage-analyzer.js
is determined by the relative path fromactual root\..
toactual root\..\node_modules\some-package
. If package path is declared asnode_modules/some-package
. the result ofgetPackageFolder()
will become the relative path fromactual root\..
toactual root\node_modules\some-package
which leads to the final resolved version looks likeactual root\actual root\node_modules\some-package
, which is incorrect.
Can you do me a favor and format this according to the issue template?
This is a possible duplicate of https://github.com/aurelia/cli/issues/278 I wrote a PR for this once (I switched to webpack now though) But you can try if the changes would help you. I wrote the code mainly to allow deeper root paths. https://github.com/aurelia/cli/pull/295
@alpox By trying your changes, you mean in what way?
@twttao you can use my fork of Aurelia-CLI to see if it works for you.
@AStoker It is updated. Thanks.
@alpox Thanks a lot for the help. But since this is a professional enterprise project I am working for, I am afraid I cannot simply fork your repository and make it production for various administrative and executive reasons.
@twttao It was not the intention to rely on my repository but rather to find out if the changes would help in your case too to figure out if you could apply an own patch on an in-enterprise repository or similar.