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

Issue 480 - Add .map file extension support to dash #478

Merged
merged 8 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As suggested, moved the side-effect outside of the path calculator and calling it directly below

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:
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved Hide resolved
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'
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved Hide resolved
})[path_in_package_dist.split('.')[-1]]
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved Hide resolved

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']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dynamic property needs to survive the sanitation process -- adding it to the list

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'