From bf21a186b62531c7fd301f090e8e1438bb710c32 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sat, 15 Mar 2025 22:22:58 +0800 Subject: [PATCH] Replace UNPKG w/ jsDelivr --- CHANGELOG.md | 1 + .../dash_core_components_base/__init__.py | 12 ++++++------ .../integration/graph/test_graph_varia.py | 2 +- .../dash_html_components_base/__init__.py | 4 ++-- .../dash-table/dash_table_base/__init__.py | 8 ++++---- components/dash-table/demo/index.html | 4 ++-- dash/_dash_renderer.py | 18 +++++++++--------- dash/dash-renderer/init.template | 18 +++++++++--------- dash/development/build_process.py | 2 +- 9 files changed, 35 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2f6776d1..f4618fbc80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). - [#3080](https://github.com/plotly/dash/pull/3080) Fix docstring generation for components using single-line or nonstandard-indent leading comments - [#3103](https://github.com/plotly/dash/pull/3103) Fix Graph component becomes unresponsive if an invalid figure is passed - [#3190](https://github.com/plotly/dash/pull/3190) Fix issue with cache key generation by adding option to include triggered inputs. Fixes [#3189](https://github.com/plotly/dash/issues/3189) +- [#3221](https://github.com/plotly/dash/issues/3221) Replace UNPKG with jsDelivr since UNPKG has not been actively maintained and has been down since `Mar 15, 2025` ## [2.18.2] - 2024-11-04 diff --git a/components/dash-core-components/dash_core_components_base/__init__.py b/components/dash-core-components/dash_core_components_base/__init__.py index 2072e1b1a2..9964fe87ef 100644 --- a/components/dash-core-components/dash_core_components_base/__init__.py +++ b/components/dash-core-components/dash_core_components_base/__init__.py @@ -61,7 +61,7 @@ { "relative_package_path": "dcc/async-{}.js".format(async_resource), "external_url": ( - "https://unpkg.com/dash-core-components@{}" + "https://cdn.jsdelivr.net/npm/dash-core-components@{}" "/dash_core_components/async-{}.js" ).format(__version__, async_resource), "namespace": "dash", @@ -76,7 +76,7 @@ { "relative_package_path": "dcc/async-{}.js.map".format(async_resource), "external_url": ( - "https://unpkg.com/dash-core-components@{}" + "https://cdn.jsdelivr.net/npm/dash-core-components@{}" "/dash_core_components/async-{}.js.map" ).format(__version__, async_resource), "namespace": "dash", @@ -91,7 +91,7 @@ { "relative_package_path": "dcc/{}.js".format(_this_module), "external_url": ( - "https://unpkg.com/dash-core-components@{}" + "https://cdn.jsdelivr.net/npm/dash-core-components@{}" "/dash_core_components/dash_core_components.js" ).format(__version__), "namespace": "dash", @@ -99,7 +99,7 @@ { "relative_package_path": "dcc/{}.js.map".format(_this_module), "external_url": ( - "https://unpkg.com/dash-core-components@{}" + "https://cdn.jsdelivr.net/npm/dash-core-components@{}" "/dash_core_components/dash_core_components.js.map" ).format(__version__), "namespace": "dash", @@ -108,7 +108,7 @@ { "relative_package_path": "dcc/{}-shared.js".format(_this_module), "external_url": ( - "https://unpkg.com/dash-core-components@{}" + "https://cdn.jsdelivr.net/npm/dash-core-components@{}" "/dash_core_components/dash_core_components-shared.js" ).format(__version__), "namespace": "dash", @@ -116,7 +116,7 @@ { "relative_package_path": "dcc/{}-shared.js.map".format(_this_module), "external_url": ( - "https://unpkg.com/dash-core-components@{}" + "https://cdn.jsdelivr.net/npm/dash-core-components@{}" "/dash_core_components/dash_core_components-shared.js.map" ).format(__version__), "namespace": "dash", diff --git a/components/dash-core-components/tests/integration/graph/test_graph_varia.py b/components/dash-core-components/tests/integration/graph/test_graph_varia.py index 373aa1fee4..9871c2d63b 100644 --- a/components/dash-core-components/tests/integration/graph/test_graph_varia.py +++ b/components/dash-core-components/tests/integration/graph/test_graph_varia.py @@ -638,7 +638,7 @@ def test_grva007_external_plotlyjs_prevents_lazy(is_eager, dash_dcc): app = Dash( __name__, eager_loading=is_eager, - external_scripts=[f"https://unpkg.com/plotly.js-dist-min@{v}/plotly.min.js"], + external_scripts=[f"https://cdn.jsdelivr.net/npm/plotly.js-dist-min@{v}/plotly.min.js"], ) app.layout = html.Div(id="div", children=[html.Button(id="btn")]) diff --git a/components/dash-html-components/dash_html_components_base/__init__.py b/components/dash-html-components/dash_html_components_base/__init__.py index fb4145dccf..db52882c4a 100644 --- a/components/dash-html-components/dash_html_components_base/__init__.py +++ b/components/dash-html-components/dash_html_components_base/__init__.py @@ -35,7 +35,7 @@ { "relative_package_path": "html/{}.min.js".format(_this_module), "external_url": ( - "https://unpkg.com/dash-html-components@{}" + "https://cdn.jsdelivr.net/npm/dash-html-components@{}" "/dash_html_components/dash_html_components.min.js" ).format(__version__), "namespace": "dash", @@ -43,7 +43,7 @@ { "relative_package_path": "html/{}.min.js.map".format(_this_module), "external_url": ( - "https://unpkg.com/dash-html-components@{}" + "https://cdn.jsdelivr.net/npm/dash-html-components@{}" "/dash_html_components/dash_html_components.min.js.map" ).format(__version__), "namespace": "dash", diff --git a/components/dash-table/dash_table_base/__init__.py b/components/dash-table/dash_table_base/__init__.py index 7e3bd250b1..b0cbb86953 100644 --- a/components/dash-table/dash_table_base/__init__.py +++ b/components/dash-table/dash_table_base/__init__.py @@ -42,7 +42,7 @@ { "relative_package_path": "dash_table/async-{}.js".format(async_resource), "external_url": ( - "https://unpkg.com/dash-table@{}" "/dash_table/async-{}.js" + "https://cdn.jsdelivr.net/npm/dash-table@{}" "/dash_table/async-{}.js" ).format(__version__, async_resource), "namespace": "dash", "async": True, @@ -58,7 +58,7 @@ async_resource ), "external_url": ( - "https://unpkg.com/dash-table@{}" "/dash_table/async-{}.js.map" + "https://cdn.jsdelivr.net/npm/dash-table@{}" "/dash_table/async-{}.js.map" ).format(__version__, async_resource), "namespace": "dash", "dynamic": True, @@ -72,14 +72,14 @@ { "relative_package_path": "dash_table/bundle.js", "external_url": ( - "https://unpkg.com/dash-table@{}/dash_table/bundle.js" + "https://cdn.jsdelivr.net/npm/dash-table@{}/dash_table/bundle.js" ).format(__version__), "namespace": "dash", }, { "relative_package_path": "dash_table/bundle.js.map", "external_url": ( - "https://unpkg.com/dash-table@{}/dash_table/bundle.js.map" + "https://cdn.jsdelivr.net/npm/dash-table@{}/dash_table/bundle.js.map" ).format(__version__), "namespace": "dash", "dynamic": True, diff --git a/components/dash-table/demo/index.html b/components/dash-table/demo/index.html index 480e65a4b5..f1b6beb1b9 100644 --- a/components/dash-table/demo/index.html +++ b/components/dash-table/demo/index.html @@ -5,8 +5,8 @@
- - + + diff --git a/dash/_dash_renderer.py b/dash/_dash_renderer.py index 6994c55fc7..161643e84e 100644 --- a/dash/_dash_renderer.py +++ b/dash/_dash_renderer.py @@ -22,16 +22,16 @@ def _set_react_version(v_react, v_reactdom=None): { "external_url": { "prod": [ - "https://unpkg.com/@babel/polyfill@7.12.1/dist/polyfill.min.js", - f"https://unpkg.com/react@{v_react}/umd/react.production.min.js", - f"https://unpkg.com/react-dom@{v_reactdom}/umd/react-dom.production.min.js", - "https://unpkg.com/prop-types@15.8.1/prop-types.min.js", + "https://cdn.jsdelivr.net/npm/@babel/polyfill@7.12.1/dist/polyfill.min.js", + f"https://cdn.jsdelivr.net/npm/react@{v_react}/umd/react.production.min.js", + f"https://cdn.jsdelivr.net/npm/react-dom@{v_reactdom}/umd/react-dom.production.min.js", + "https://cdn.jsdelivr.net/npm/prop-types@15.8.1/prop-types.min.js", ], "dev": [ - "https://unpkg.com/@babel/polyfill@7.12.1/dist/polyfill.min.js", - f"https://unpkg.com/react@{v_react}/umd/react.development.js", - f"https://unpkg.com/react-dom@{v_reactdom}/umd/react-dom.development.js", - "https://unpkg.com/prop-types@15.8.1/prop-types.js", + "https://cdn.jsdelivr.net/npm/@babel/polyfill@7.12.1/dist/polyfill.min.js", + f"https://cdn.jsdelivr.net/npm/react@{v_react}/umd/react.development.js", + f"https://cdn.jsdelivr.net/npm/react-dom@{v_reactdom}/umd/react-dom.development.js", + "https://cdn.jsdelivr.net/npm/prop-types@15.8.1/prop-types.js", ], }, "relative_package_path": { @@ -64,7 +64,7 @@ def _set_react_version(v_react, v_reactdom=None): { "relative_package_path": "dash-renderer/build/dash_renderer.min.js", "dev_package_path": "dash-renderer/build/dash_renderer.dev.js", - "external_url": "https://unpkg.com/dash-renderer@1.21.1" + "external_url": "https://cdn.jsdelivr.net/npm/dash-renderer@1.21.1" "/build/dash_renderer.min.js", "namespace": "dash", }, diff --git a/dash/dash-renderer/init.template b/dash/dash-renderer/init.template index 01bcbd5c74..a375367c37 100644 --- a/dash/dash-renderer/init.template +++ b/dash/dash-renderer/init.template @@ -22,16 +22,16 @@ def _set_react_version(v_react, v_reactdom=None): { "external_url": { "prod": [ - "https://unpkg.com/@babel/polyfill@$polyfill/dist/polyfill.min.js", - f"https://unpkg.com/react@{v_react}/umd/react.production.min.js", - f"https://unpkg.com/react-dom@{v_reactdom}/umd/react-dom.production.min.js", - "https://unpkg.com/prop-types@$proptypes/prop-types.min.js", + "https://cdn.jsdelivr.net/npm/@babel/polyfill@$polyfill/dist/polyfill.min.js", + f"https://cdn.jsdelivr.net/npm/react@{v_react}/umd/react.production.min.js", + f"https://cdn.jsdelivr.net/npm/react-dom@{v_reactdom}/umd/react-dom.production.min.js", + "https://cdn.jsdelivr.net/npm/prop-types@$proptypes/prop-types.min.js", ], "dev": [ - "https://unpkg.com/@babel/polyfill@$polyfill/dist/polyfill.min.js", - f"https://unpkg.com/react@{v_react}/umd/react.development.js", - f"https://unpkg.com/react-dom@{v_reactdom}/umd/react-dom.development.js", - "https://unpkg.com/prop-types@$proptypes/prop-types.js", + "https://cdn.jsdelivr.net/npm/@babel/polyfill@$polyfill/dist/polyfill.min.js", + f"https://cdn.jsdelivr.net/npm/react@{v_react}/umd/react.development.js", + f"https://cdn.jsdelivr.net/npm/react-dom@{v_reactdom}/umd/react-dom.development.js", + "https://cdn.jsdelivr.net/npm/prop-types@$proptypes/prop-types.js", ], }, "relative_package_path": { @@ -64,7 +64,7 @@ _js_dist = [ { "relative_package_path": "dash-renderer/build/dash_renderer.min.js", "dev_package_path": "dash-renderer/build/dash_renderer.dev.js", - "external_url": "https://unpkg.com/dash-renderer@$version" + "external_url": "https://cdn.jsdelivr.net/npm/dash-renderer@$version" "/build/dash_renderer.min.js", "namespace": "dash", }, diff --git a/dash/development/build_process.py b/dash/development/build_process.py index 8f534d56e2..974f5a1f8d 100644 --- a/dash/development/build_process.py +++ b/dash/development/build_process.py @@ -143,7 +143,7 @@ def bundles(self, build=None): # pylint:disable=too-many-locals versions[f"extra_{name_squashed}_versions"] = f'"{extras_str}"' for extra_version in extras: - url = f"https://unpkg.com/{name}@{extra_version}/umd/{filename}" + url = f"https://cdn.jsdelivr.net/npm/{name}@{extra_version}/umd/{filename}" res = requests.get(url) extra_target = f"{name}@{extra_version}.{ext}" extra_path = self._concat(self.deps_folder, extra_target)