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

Better way to use require fallback? #2026

Merged
merged 3 commits into from
Apr 4, 2018
Merged

Conversation

vidartf
Copy link
Member

@vidartf vidartf commented Mar 28, 2018

See discussion in jupyter-widgets/pythreejs#171 .

@jasongrout
Copy link
Member

@maartenbreddels - can you review this one, as you were involved in the issue over in pythreejs?

@jasongrout jasongrout added this to the 7.2 milestone Mar 28, 2018
@jasongrout
Copy link
Member

This can also go into a patch release of html manager, so we don't have to rush it for 7.2.

@jasongrout jasongrout modified the milestones: 7.2, Patch release Mar 29, 2018
@maartenbreddels
Copy link
Member

Let me check this one, I think the idea is solid.

Copy link
Member

@maartenbreddels maartenbreddels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one issue, but even when I fixed that and try
require_1.toUrl(moduleName) which gives good output, it does not lead to a network request.
Isn't a better solution for jupyter-threejs to provide an anonymous module?

}
require.config({
paths: {
moduleName: moduleNameToCDNUrl(moduleName, moduleVersion)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will add a key 'moduleName', I think you need to do sth like

            let config = {paths: {}}
            config.paths[moduleName] = moduleNameToCDNUrl(moduleName, moduleVersion)

You should be able to put [] around moduleName, but the resulting js was without that, so I wouldn't rely on that.

@maartenbreddels
Copy link
Member

Ok, the issue is that require already 'knows' 'jupyter-threejs' failed, since it requested it before doing the CDN request (it queried for ./jupyter-threejs.js), and refuses to do so again. This can be fixed using require.undef('jupyter-threejs'), say in requireLoader, after the catch.

@maartenbreddels
Copy link
Member

Didn't work, you need to take off the .js part, sth like this:

            var url = moduleNameToCDNUrl(moduleName, moduleVersion)
            conf.paths[moduleName] = url.substring(0, url.length-3);

@vidartf
Copy link
Member Author

vidartf commented Mar 31, 2018

Since the function is not exported, I just removed the .js part from the return value.

@vidartf
Copy link
Member Author

vidartf commented Apr 4, 2018

This works for me locally now.

@maartenbreddels
Copy link
Member

yes works here too.

@maartenbreddels maartenbreddels merged commit 05b6bcb into master Apr 4, 2018
@vidartf vidartf deleted the require-fallback branch April 4, 2018 12:52
@jasongrout jasongrout modified the milestones: Patch release, 7.3 Jul 6, 2018
@lock lock bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label May 21, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants