diff --git a/@plotly/webpack-dash-dynamic-import/src/index.js b/@plotly/webpack-dash-dynamic-import/src/index.js index b02a7edc70..6071c0a97b 100644 --- a/@plotly/webpack-dash-dynamic-import/src/index.js +++ b/@plotly/webpack-dash-dynamic-import/src/index.js @@ -5,7 +5,7 @@ function getFingerprint() { const packageJson = JSON.parse(package); const timestamp = Math.round(Date.now() / 1000); - const version = packageJson.version.replace(/[.]/g, '_'); + const version = packageJson.version.replace(/[^\w-]/g, '_'); return `"v${version}m${timestamp}"`; } diff --git a/CHANGELOG.md b/CHANGELOG.md index b0698b3a3f..b28ab05f95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased ### Fixed +- [#999](https://github.com/plotly/dash/pull/999) Fix fingerprint for component suites with `metadata` in version. - [#983](https://github.com/plotly/dash/pull/983) Fix the assets loading issues when dashR application runner is handling with an app defined by string chunk. ## [1.5.1] - 2019-10-29 diff --git a/dash/fingerprint.py b/dash/fingerprint.py index b9c23d3034..78df1d4917 100644 --- a/dash/fingerprint.py +++ b/dash/fingerprint.py @@ -1,7 +1,7 @@ import re cache_regex = re.compile(r"^v[\w-]+m[0-9a-fA-F]+$") - +version_clean = re.compile(r"[^\w-]") def build_fingerprint(path, version, hash_value): path_parts = path.split("/") @@ -9,7 +9,7 @@ def build_fingerprint(path, version, hash_value): return "{}.v{}m{}.{}".format( "/".join(path_parts[:-1] + [filename]), - str(version).replace(".", "_"), + re.sub(version_clean, "_", str(version)), hash_value, extension, ) diff --git a/tests/integration/devtools/test_props_check.py b/tests/integration/devtools/test_props_check.py index 95d81349ac..b9d7155660 100644 --- a/tests/integration/devtools/test_props_check.py +++ b/tests/integration/devtools/test_props_check.py @@ -216,7 +216,7 @@ def test_dvpc001_prop_check_errors_with_path(dash_duo): - app = dash.Dash(__name__) + app = dash.Dash(__name__, eager_loading=True) app.layout = html.Div([html.Div(id="content"), dcc.Location(id="location")]) diff --git a/tests/unit/test_fingerprint.py b/tests/unit/test_fingerprint.py index 36de80ddcc..97037e7bb5 100644 --- a/tests/unit/test_fingerprint.py +++ b/tests/unit/test_fingerprint.py @@ -17,6 +17,12 @@ "version": "1.1.1-alpha.1", "hash": "1234567890abcdef", }, + { + "path": "react@16.8.6.min.js", + "fingerprint": "react@16.v1_1_1-alpha_x_y_y_X_Y_Z_1_2_3_metadata_xx_yy_zz_XX_YY_ZZ_11_22_33_mmm1234567890abcdefABCDEF.8.6.min.js", + "version": "1.1.1-alpha.x.y.y.X.Y.Z.1.2.3+metadata.xx.yy.zz.XX.YY.ZZ.11.22.33.mm", + "hash": "1234567890abcdefABCDEF", + }, {"path": "dash.plotly.js", "fingerprint": "dash.v1m1.plotly.js"}, {"path": "dash.plotly.j_s", "fingerprint": "dash.v1m1.plotly.j_s"}, {"path": "dash.plotly.css", "fingerprint": "dash.v1m1.plotly.css"},