diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e80c7eff..6566d3d0d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.32.0 - 2018-12-07 +## Added +- Support for .map file extension and dynamic (on demand) loading [#478](https://github.com/plotly/dash/pull/478) + ## 0.31.1 - 2018-11-29 ## Fixed - Fix `_imports_.py` indentation generation. [#473](https://github.com/plotly/dash/pull/473/files) @@ -101,7 +105,7 @@ - Take configs values from init or environ variables (Prefixed with `DASH_`). [#322](https://github.com/plotly/dash/pull/322) ## Fixed -- Take `requests_pathname_prefix` config when creating scripts tags. +- Take `requests_pathname_prefix` config when creating scripts tags. - `requests/routes_pathname_prefix` must starts and end with `/`. - `requests_pathname_prefix` must ends with `routes_pathname_prefix`. If you supplied both `requests` and `routes` pathname before this update, make sure `requests_pathname_prefix` ends with the same value as `routes_pathname_prefix`. - `url_base_pathname` set both `requests/routes` pathname, cannot supply it with either `requests` or `routes` pathname prefixes. diff --git a/dash/dash.py b/dash/dash.py index 3beb789871..a75d4c4c21 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -359,9 +359,6 @@ def _collect_and_register_resources(self, resources): # for cache busting def _relative_url_path(relative_package_path='', namespace=''): - # track the registered packages - self.registered_paths[namespace].add(relative_package_path) - module_path = os.path.join( os.path.dirname(sys.modules[namespace].__file__), relative_package_path) @@ -378,11 +375,17 @@ def _relative_url_path(relative_package_path='', namespace=''): srcs = [] for resource in resources: + is_dynamic_resource = resource.get('dynamic', False) + if 'relative_package_path' in resource: - if isinstance(resource['relative_package_path'], str): - srcs.append(_relative_url_path(**resource)) - else: - for rel_path in resource['relative_package_path']: + paths = resource['relative_package_path'] + paths = [paths] if isinstance(paths, str) else paths + + for rel_path in paths: + self.registered_paths[resource['namespace']]\ + .add(rel_path) + + if not is_dynamic_resource: srcs.append(_relative_url_path( relative_package_path=rel_path, namespace=resource['namespace'] @@ -492,7 +495,8 @@ def serve_component_suites(self, package_name, path_in_package_dist): mimetype = ({ 'js': 'application/JavaScript', - 'css': 'text/css' + 'css': 'text/css', + 'map': 'application/json' })[path_in_package_dist.split('.')[-1]] headers = { diff --git a/dash/resources.py b/dash/resources.py index 603bd37afe..476ad33839 100644 --- a/dash/resources.py +++ b/dash/resources.py @@ -19,6 +19,8 @@ def _filter_resources(self, all_resources, dev_bundles=False): filtered_resources = [] for s in all_resources: filtered_resource = {} + if 'dynamic' in s: + filtered_resource['dynamic'] = s['dynamic'] if 'namespace' in s: filtered_resource['namespace'] = s['namespace'] if 'external_url' in s and not self.config.serve_locally: diff --git a/dash/version.py b/dash/version.py index 74f9490deb..2ef0c52ebf 100644 --- a/dash/version.py +++ b/dash/version.py @@ -1 +1 @@ -__version__ = '0.31.1' +__version__ = '0.32.0'