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

[WIP] Export modules for AMD consumption #1793

Closed
wants to merge 4 commits into from

Conversation

blink1073
Copy link
Member

@blink1073 blink1073 commented Sep 28, 2016

cf #1554 (comment)

  • Break the pages into vendor and main using the WebPack DllPlugin.
  • Use a script to generate a RequireJS bundle from the DLL manifest.
  • The script will walk through the manifest contents and create define functions of the form:
define('base/js/auth', function() { return vendor(100); });
  • We get the path by replacing ./notebook/static/ with '' and ./node_modules/ with '' and stripping out the .js (along with making sure it has a .js extension first).
  • The HTML template will include the RequireJS bundle after including the vendor bundle and RequireJS itself.
  • After that, all modules on the page are available using the previous AMD require semantics.

Here is what the manifest looks like for the terminal:

{
  "name": "vendor",
  "content": {
    "./notebook/static/terminal/js/main.js": 1,
    "./node_modules/xterm/src/xterm.css": 2,
    "./node_modules/css-loader/index.js!./node_modules/xterm/src/xterm.css": 3,
    "./node_modules/css-loader/lib/css-base.js": 4,
    "./node_modules/style-loader/addStyles.js": 5
  }
}

And the resulting shim is:

define("terminal/js/main", function () { return vendor(1); });
define("css-loader/lib/css-base", function () { return vendor(4); });
define("style-loader/addStyles", function () { return vendor(5); });

Status

The WebPack bundles and manifests and shims are created and the tree page is functional.

@blink1073
Copy link
Member Author

blink1073 commented Sep 28, 2016

Drat. In order for this to work all of the modules will have to be converted to be fully CommonJS. Otherwise the bulk of the modules end up in 1.vendor.js and are not in the DLL manifest.

@blink1073
Copy link
Member Author

@gnestor, @minrk. I am 100% convinced this will work if I implement the above, but it is going to be time consuming and invasive.

@minrk
Copy link
Member

minrk commented Oct 5, 2016

I like it in principle, but I don't like how much work we are making you do on this. @blink1073 what do you think about the tradeoffs in terms of effort of getting webpack to not break requirejs here vs going back to requirejs with no webpack?

@blink1073
Copy link
Member Author

blink1073 commented Oct 5, 2016

Looking at the package.json, all of the dependencies are available on bower. I'd say going back to being bower + requirejs-only is the way to go. It is the least brittle solution, since the above solution requires making sure everything is available as a commonjs import and stays that way.

@minrk
Copy link
Member

minrk commented Oct 5, 2016

I'd say going back to being bower + requirejs-only is the way to go

That makes sense to me. I took a stab at exactly that a while back, but too many webpack changes had been made for it to be really easy, and I ran out of time.

@blink1073
Copy link
Member Author

I'll close this one then. :(

@blink1073 blink1073 closed this Oct 5, 2016
@minrk minrk added this to the no action milestone Nov 23, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants