Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle http files #23

Open
revolunet opened this issue Apr 4, 2013 · 7 comments
Open

handle http files #23

revolunet opened this issue Apr 4, 2013 · 7 comments

Comments

@revolunet
Copy link

Hi Matt,

I'm not sure about this, but would it be possible to handle http served files instead of local files ? I mean i have some index dynamically generated (eg:php) and would be cool to analyse it directly instead of a local index.html.

if it is then we could work on a PR with that feature.

Thanks

@revolunet
Copy link
Author

Matt,

Can you please explain why can't we just open the index.html/php file in phantomjs and live switch the debug-all.js file to debug.js and inject the bridge directly ?
I think we can intercept in the onResourceRequestedand change file accordingly, dont you ?

Instead of creating a tempfile; Maybe i miss some points though so your opinion is very appreciated.

Thanks

@mattgoldspink
Copy link
Owner

@revolunet Yes - that makes perfect sense, especially when adding support for remote files. I guess my only question is how should we best let the user configure the path to map the remote files to local ones. We'd need to convert the requested url's to local ones on disk, I guess some mapping configuration like:

     urlMapping: {
         '/lib': 'app/lib'
     }

Any thoughts/opinions?
I'll take a stab at refactoring the current code to do this over the weekend.

@revolunet
Copy link
Author

Thanks Matt; but why would we need local mapping ?

My naive opinion is that we can directly open the web page, analyse the loader and extract all the dependencies directly, cant we ?

@mattgoldspink
Copy link
Owner

The idea with this task was to be able to JUST generate a list of files for other tasks to use. This gives a greater flexibility of what people can do next:

  • validate with jslint/jshint
  • concat with uglify/closure/yui - if you have multiple Ext pages you can run the task twice and find the intersection of files to generate more optimised files
  • generate relevant docs/stats e.g. show me all files in my project which aren't loaded any more by my app or generate a Plato report on them

This keeps both this task nice and simple - I don't have to bother writing a concat/minifier/xyz next step feature that people might want to use in their build pipeline.

Unfortunately these other grunt tasks won't work with 'http' url, they all are all based on files on disk, hence the need for the mapping from a http request to the local file on disk.

@revolunet
Copy link
Author

Ok thanks, i understand, you're perfectly right, separations of concerns is what makes grunt so flexible and powerful.

So your url mapping proposal makes sense. We just need to setup (one or more) url to path mapping in the config.

Do you think the "live changing of the source" approach (using phantomjs onResourceRequested) makes sense ?

Id be please to help so if i can investigate/code something, just tell me :)

Thanks

@mattgoldspink
Copy link
Owner

@revolunet Sorry for the lack of response on this. I started working on it last weekend and quickly hit some problems that I've not managed to solve. The problem I'm facing is that I don't get passed a networkRequest object in the onResourceRequested callback. So it's not possible for me to change the url. I spent a bit of time trying to figure out why - I have a feeling it could be due to the requests being made for filesystem urls and not http urls, but I'm not 100% sure.

Feel free to take a look into this if you want to. I'm sure two people looking into it will help get it done a little quicker.

@revolunet
Copy link
Author

@mattgoldspink : thanks for looking at this.

We're making some tests in that direction with a different approach and will give you our results asap.

From what i understand, all the dependency 'detection' is made using Ext.Loader.history when the application startsup. But this doesn't cover dependencies loaded by objects that appear later in the application, does it ?

Eg: i have a button that instantiate a custom class that uses some new Ext layout or xtypes. Using ext-debug.js we can see that the files are loaded "on demand" and not on application startup and thus the dependency is not detected.

How could we deal with this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants