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

Compute the public path automatically #988

Merged
merged 4 commits into from
Jun 17, 2022

Conversation

jasongrout
Copy link
Member

This updates the public path computation to use built-in require.js facilities, which means we no longer need to hardcode the public path, nor distinguish between the classic notebook extension and the CDN bundle.

See also jupyter-widgets/widget-cookiecutter#103

This means the files should be able to be hosted on any CDN.

Also update the webpack image loaders to use the new asset/resource type.

See also jupyter-widgets/ipywidgets#3464 and jupyter-widgets/widget-cookiecutter#103
It seems that the auto public path logic in webpack does not work for AMD modules, since document.currentScript only works when the script is initially executed, not in a callback. In the cases where we know we are compiling to an AMD module, we can use the requirejs magic 'module' dependency to get the url of the file, and from that do our own auto public path magic.

We encapsulate this auto public path setting into its own file so that it does not intrude on user code, and is only used when we know in the webpack config that we are compiling to an AMD module.

See also jupyter-widgets/widget-cookiecutter#103
@jasongrout jasongrout requested a review from martinRenou June 14, 2022 23:08
@jasongrout jasongrout mentioned this pull request Jun 14, 2022
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Thanks! Just a minor review comment

js/webpack.config.js Outdated Show resolved Hide resolved
Co-authored-by: martinRenou <martin.renou@gmail.com>
@jasongrout jasongrout requested a review from martinRenou June 16, 2022 18:32
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants