yoavniran / grunt-systemjs-builder

grunt task for building systemjs based projects
6 stars 4 forks source link

grunt `files` expansion processing and builder's baseURL break configuration #9

Open MisterFreeze opened 8 years ago

MisterFreeze commented 8 years ago

Hello,

for two reasons, I think that grunt's files logic and builder's baseURL setting collide. First, I cannot give a src relative to the gruntfile (except using './') because when using a baseURL, its value is prepended by systemjs-builder to determine the source files's location. So I would have to use a path relative to baseURL. This, however, breaks for grunt's files expansion.

Example 1 (breaks):

file: ./static/js/main.js baseURL: static src: js/main

Example 1 does not work because file.src is undefined as grunt's files logic cannot find ./js/main. systemjs-builder, however, would find the correct source file.

Example 2 (breaks):

file: ./static/js/main.js baseURL: static src: static/js/main.js

Example 2 gives a valid file.src value but systemjs-builder expands it to static/static/js/main.js, which does not exist.

Example 3 (works):

file: ./static/js/main.js baseURL: static src: ./static/js/main.js

Example 3 works as grunt's file logic finds that file and systemjs-builder does not prepend the baseURL value as it recognizes the explicit relative path ('./').

Idea

I would suggest not to use grunt's files logic at all and let systemjs-builder do the source file expansion. This would also allow for arithmetic builds. My suggestion can be found summarized in #7 .

Kind regards

yoavniran commented 8 years ago

hi @MisterFreeze before I can dive into this more thoroughly I wanted to clarify something: In your post you keep mentioning "Bower" but I think you mean "Grunt". is that correct?

thanks, Yoav

MisterFreeze commented 8 years ago

Hi @yoavniran , you are correct. I will change this to grunt :)

yoavniran commented 8 years ago

In the project im working on now I have this set up and it works well:

options.baseURL = "./target/widget" files src = "./target/widget/src/init.js"

Would this not be a good solution for you @MisterFreeze ?

MisterFreeze commented 8 years ago

Hi,

This is what I did in example 3 and it currently is the only solution I am able to get it running with. For two reasons, I do not think that this solution is good. Firstly, baseURL is not honored in this setup. This makes this configuration parameter completely useless and also may confuse users familiar with systemjs-builder. Secondly, the usage of grunt's files processing breaks the systemjs-builder's source file lookup logic and will make implementation of arithmetic builds more complicated, as I pointed out in #7.

Let me summarize this. I am aware of the workaround you suggested but I do not like workarounds to be a mid-term solution. I am willing to contribute to this project to improve it.

Best regards,

MisterFreeze