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

loading JS files confuses the module system #429

Closed
scottdraves opened this issue Jul 31, 2014 · 4 comments
Closed

loading JS files confuses the module system #429

scottdraves opened this issue Jul 31, 2014 · 4 comments

Comments

@scottdraves
Copy link
Contributor

See #421

basically if JS in a cell calls loadJS or loadList, and the loaded code tries to define a module, it will fail to load.

probably these function should do the define = undefined trick.

@scottdraves
Copy link
Contributor Author

Unfortunately bkHelper.loadList can't just do the "defined = undefined" trick because it has to be in force then the fetched code is evaluated which happens asynchronously. we could use the success/failure callbacks to reset it back but that means that while it's running other code would also be tricked.

it might help if the javascript plugin had list of URLs to load in its spec and it handled them automatically?
if that works it would be great because it hides the use of loadList which is also too much for users, and more like setting up the classpath which is more well known.

also maybe we should just always have "define = undefined" in the user's javascript.

@melmac48 melmac48 modified the milestones: version 2.0, version 1.0 Sep 8, 2014
@scottdraves
Copy link
Contributor Author

This is actually harder than that to do right. The problem is if you have a notebook that loads a random JS file, then uses that code say to create an interactive chart, then you share the notebook, it will not work on the sharing server. And if someone downloads the notebook from the sharing server, then it would not work for them until they download and install the dependency.

So I propose an "importJS" command that not only loads the JS properly, but actually stores it in the notebook (in the namespace). This is actually a general problem for notebooks, not only for loading JS file but other random files that might be read by the code in a notebook. in each language, in the beaker runtime, we can provide this wrapped load function that caches the result in the notebook. It should check the file modtime every time it runs, and if the original file has been modified it should read it again.

@scottdraves
Copy link
Contributor Author

a complication with the above is if the loaded JS file recursively loads other JS files.
ideally you would detect that and cache them all in the notebook namespace.

@scottdraves
Copy link
Contributor Author

new plan: in the language manager have some GUI for finding libs (eg bower github file url). when found, include in the notebook, and then have them loaded and accessible to code run in JS cells.

tomca32 added a commit that referenced this issue Apr 14, 2016
…corated the ui-select-sort directive to disable dragging in ui-select
tomca32 added a commit that referenced this issue Apr 19, 2016
tomca32 added a commit that referenced this issue Apr 19, 2016
tomca32 added a commit that referenced this issue Apr 19, 2016
…corated the ui-select-sort directive to disable dragging in ui-select
tomca32 added a commit that referenced this issue Apr 22, 2016
tomca32 added a commit that referenced this issue Apr 22, 2016
tomca32 added a commit that referenced this issue Apr 22, 2016
tomca32 added a commit that referenced this issue Apr 26, 2016
tomca32 added a commit that referenced this issue Apr 26, 2016
tomca32 added a commit that referenced this issue Apr 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants