Skip to content

Commit

Permalink
Merge pull request #478 from plotly/dash-support-map-files
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-Andre-Rivet committed Dec 7, 2018
2 parents cc6bd35 + c4f4c49 commit b0ea2f4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.
Expand Down
20 changes: 12 additions & 8 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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']
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions dash/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dash/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.31.1'
__version__ = '0.32.0'

0 comments on commit b0ea2f4

Please sign in to comment.