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
Replace webpack with require.js #1554
Comments
So far we have limped along by pulling things out of the WebPack bundle that might be required using RequireJS (jQuery, CodeMirror). For things that should be in the bundle (like |
Yeah, and that's no good because everything should be loadable by require—certainly notebook, cell, outputarea, etc. We are only bundling them for load-time optimization. When we did the bundling with require, it had no effect on the behavior, only an optimization. Pulling things out to script tags undoes all that. |
Technically we could use a DllPlugin to create the shared bundle, use the DllReferencePlugin to consume the bundle from Webpack, and find/write a way to generate a RequireJS config using the manifest created by the DllPlugin. |
We could try that. I'm not sure if there's a benefit to using webpack in this repo given our backward-compatbility goals, though. I think the main reason was that it's what we want to use in new projects, so we should be consistent, but with lab in its own repo I think that makes less sense now. Are there benefits to webpack over require.js in this repo? |
I'm looking at this from the opposite side as well, how do we load external things in JupyterLab, or do we want to force everything to be WebPacked? That would mean, for instance, that installing/uninstalling an extension would require a rebuild of WebPack. We could still support dynamic enable/disable by using the html template to define the bootstrapping code for the application, and use the desired modules from the bundle. |
I think that's not going to work. We cannot require running webpack to be a runtime dependency for using an extension. I expect that we should be able to deal with this in JupyterLab by making the extension points more clearly defined exported functions / events / observables / etc., Rather than allowing full access to everything in extensions. If we do that, extensions shouldn't need to be able to extend prototypes on Cell, etc. which is the source of the problems we have in the notebook right now (and then the fact that they cannot extend these prototypes becomes a good thing). |
I am fine backing out of using webpack in the classic notebook... On Fri, Jun 17, 2016 at 3:16 AM, Min RK notifications@github.com wrote:
Brian E. Granger |
I had thought we could rectify the use of Webpack and RequireJS, but existing extensions rely on the ability to I recommend taking the stance that the Notebook is and always will be AMD-only and use RequireJS. |
@gnestor, thoughts on this? |
Let me start out by saying that I don't have any experience using AMD and RequireJS and I have a lot of experience using CommonJS and Webpack. Webpack is great because it allows you to use a lot of the good things about Node.js (CommonJS, npm) within the browser by bundling all of your modules into a file that can be used within a
It appears that all of these options would enable extensions to access the notebook core by exposing the notebook core to the global context, which is not a good solution.
I have experience developing Atom packages and if you look at Atom's API, it also exposes an I'm not familiar with the current notebook- or jupyterlab-extension API, so I would need to see some docs/examples to offer any suggestions regarding to Webpack or not to Webpack. @rgbkrk I know that nteract is using Electron (the same native shell that Atom uses) and therefore doesn't require Webpack, but do you have any insights nonetheless? |
Seems like we can never divest from requirejs based on previous usage of and reliance on AMD. I'll go ahead and stand by @blink1073 in saying "that the Notebook is and always will be AMD-only and use RequireJS.", while hanging my head 😢. Thanks for giving it a go. As for nteract and Electron, we face the same problem as in jupyter/roadmap#9 and #116, regardless of the module loader. I don't have any solutions though. |
/cc @jdfreder |
Proposal: use the DllPlugins for the notebook itself and use the resulting manifest to generate |
@blink1073 This sounds like it's worth a try. I'm happy to help although I think you have a better understanding of how to go about implementing it. Do you want to give it a shot? Also, what is the priority level of this (1 being this should be worked on whenever and 5 being this should be worked on immediately)? @minrk Thoughts? |
I'll take a stab at it next week. |
Sounds like it's worth a shot. A while back, I took a stab at reverting to the old requirejs setup entirely for the legacy notebook, but too many webkit-based things have crept in that made it pretty difficult, and I had to move on to other things. I don't care about the build tools too much, as long as we can fix the runtime-require behavior that users are already relying upon. |
In the interest of releasing 5.0 soon, I think it's time to act on this. I will certainly help or take the lead on this if necessary. Here is the webpack PR with 36 commits! I don't know if there is a semi-automatic way to revert a PR/merge, but if there is that could be a good place to start. Thoughts? |
Proposal from #1547: go back to using require.js for this notebook, and leave webpack for newer projects, such as jupyterlab.
The switch to webpack in the legacy notebook seems to make lots of backward-compatibility maintenance impossible, and has been the source of numerous issues (#1547, #1439, #1431, etc.). Following some discussion in #1547, I think it's not feasible to maintain our goals of backward-compatibility in the existing notebook javascript while adopting webpack. The key point being that it seems to be impossible to include a module in the webpack, and then load it later with require, which is a necessity for numerous extensions and official APIs.
If that's not true, and we are just failing to configure things correctly, there might be a nicer, simpler fix. But this gist is, for the notebook js the following two things must return the same object:
require('notebook/js/cell')
in our packed-up sourcesrequire('notebook/js/cell')
at runtime, in outputs, custom.js, or nbextensions(and so on, for codemirror and everything else we load via require). The behavior in master is to load a different copy of the module, which is causing all kinds of things to break.
The text was updated successfully, but these errors were encountered: