Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/more-efficient-bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Aug 29, 2016
2 parents 00f284f + 1f46dbd commit c8331d1
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Expand Up @@ -15,14 +15,19 @@ after_success:
env:
- TOXENV=py27-django18
- TOXENV=py27-django19
- TOXENV=py27-django110

- TOXENV=pypy-django18
- TOXENV=pypy-django19
- TOXENV=pypy-django110

- TOXENV=py33-django18

- TOXENV=py34-django18
- TOXENV=py34-django19
- TOXENV=py34-django110

- TOXENV=py35-django18
- TOXENV=py35-django19
- TOXENV=py35-django110

31 changes: 20 additions & 11 deletions Changelog.rst
@@ -1,6 +1,15 @@
Changelog
=========

1.3.3
-----

* Optimization: build a bundle only once. Before, if a bundle was used in
multiple templates, it would be bundled again for every appearance. Thanks to
**pcompassion** for the report (`#15`_).

.. _#15: https://github.com/sergei-maertens/django-systemjs/issues/15

1.3.2
-----

Expand Down Expand Up @@ -31,7 +40,7 @@ Changelog

Fixes loading of the configuration options in tests.

In previous releases, using `django.test.utils.override_settings` in certain
In previous releases, using ``django.test.utils.override_settings`` in certain
ways happened before the django-systemjs settings were appended. This was
probably only the case for Django < 1.9.

Expand Down Expand Up @@ -78,14 +87,14 @@ Fixes some mistakes from 0.3.3. Mondays...

0.3.3
-----
Added post-processing of `jspm_packages/system.js` if it is within
`settings.STATIC_ROOT`.
Added post-processing of ``jspm_packages/system.js`` if it is within
``settings.STATIC_ROOT``.

This introduces a new setting: `SYSTEMJS_PACKAGE_JSON_DIR`. Set this to the path
of the folder containing `package.json`. `package.json` will be inspected to
This introduces a new setting: ``SYSTEMJS_PACKAGE_JSON_DIR``. Set this to the path
of the folder containing ``package.json``. ``package.json`` will be inspected to
figure out the install path of jspm - and only post-process if the latter path
is within `settings.STATIC_ROOT`. By default, `settings.BASE_DIR` (provided by
the default `django-admin.py startproject` template) will be chosen for this
is within ``settings.STATIC_ROOT``. By default, ``settings.BASE_DIR`` (provided by
the default ``django-admin.py startproject`` template) will be chosen for this
directory.

0.3.2
Expand All @@ -98,21 +107,21 @@ Fixed incorrect passing of the --log option.
No API changes where made - this release is preparation for Django 1.9 and
improves robustness of bundling.

In version 0.16.3 `--log` was added to JSPM. This allows us to properly check
In version 0.16.3 ``--log`` was added to JSPM. This allows us to properly check
for build errors, where before you would find out the hard way. Build errors
will now show as output from the management command.

An check has been added to figure out the JSPM version. If you get a
`BundleError` saying that the JSPM version could not be determined, check that
`jspm` is available in your path or modify the `SYSTEMJS_JSPM_EXECUTABLE`
``BundleError`` saying that the JSPM version could not be determined, check that
``jspm`` is available in your path or modify the ``SYSTEMJS_JSPM_EXECUTABLE``
setting accordingly.


0.3.0
-----

Changed the templatetag to add the .js extension. Existing code should still
work, possibly you need to set System.defaultJSExtensions to `true`.
work, possibly you need to set System.defaultJSExtensions to ``true``.


.. note::
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Expand Up @@ -35,8 +35,8 @@ and ties in perfectly with ``django.contrib.staticfiles``.
Requirements
============

Django-Systemjs runs on Python 2.7, 3.3, 3.4 and 3.5. Django versions 1.8 and
1.9 are supported.
Django-Systemjs runs on Python 2.7, 3.3, 3.4 and 3.5. Django versions 1.8, 1.9 and
1.10 are supported.



Expand Down
9 changes: 5 additions & 4 deletions runtests.py
Expand Up @@ -3,7 +3,7 @@
import sys


def runtests(*args):
def runtests(*tests):
test_dir = os.path.dirname(__file__)
sys.path.insert(0, test_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
Expand All @@ -16,9 +16,10 @@ def runtests(*args):

TestRunner = get_runner(settings)
test_runner = TestRunner(verbosity=1, interactive=True)
if not args:
args = (['.'],)
failures = test_runner.run_tests(*args)

if not tests:
tests = (['.'],)
failures = test_runner.run_tests(*tests)
sys.exit(failures)


Expand Down
2 changes: 1 addition & 1 deletion systemjs/__init__.py
Expand Up @@ -7,7 +7,7 @@
import subprocess


VERSION = (1, 4, 0, 'beta', 2)
VERSION = (1, 4, 0, 'beta', 3)


default_app_config = 'systemjs.apps.SystemJSConfig'
Expand Down
16 changes: 16 additions & 0 deletions tests/tests/helpers.py
@@ -1,5 +1,10 @@
from __future__ import unicode_literals

from copy import deepcopy

from django.conf import settings
from django.test import override_settings

import mock


Expand All @@ -13,3 +18,14 @@ def mock_Popen(mock_subproc_popen, return_value=None, side_effect=None):
process_mock.configure_mock(**attrs)
mock_subproc_popen.return_value = process_mock
return process_mock


def add_tpl_dir(path):
"""
Adds a template dir to the settings.
Decorator that wraps around `override_settings`.
"""
templates = deepcopy(settings.TEMPLATES)
templates[0]['DIRS'].append(path)
return override_settings(TEMPLATES=templates)
1 change: 1 addition & 0 deletions tests/tests/templates1/same_bundle.html
@@ -0,0 +1 @@
{% load system_tags %}{% systemjs_import 'app/dummy' %}
18 changes: 18 additions & 0 deletions tests/tests/test_management.py
Expand Up @@ -18,6 +18,8 @@

from semantic_version import Version

from .helpers import add_tpl_dir


JINJA_TEMPLATES = [{
'BACKEND': 'django.template.backends.jinja2.Jinja2',
Expand Down Expand Up @@ -190,6 +192,22 @@ def test_templates_option_wrong_tpl(self, bundle_mock):
self.assertEqual(_num_files(settings.STATIC_ROOT), 0)
self.assertEqual(bundle_mock.call_count, 0)

@add_tpl_dir(os.path.join(os.path.dirname(__file__), 'templates1'))
def test_same_bundle_multiple_templates(self, bundle_mock):
"""
Test that a module is bundled only once if it appears in multiple
template files.
"""
bundle_mock.side_effect = _bundle

self.assertEqual(_num_files(settings.STATIC_ROOT), 0)
call_command('systemjs_bundle', stdout=self.out, stderr=self.err)
self.assertEqual(_num_files(settings.STATIC_ROOT), 1)

# one app found in multiple templates -> should only be bundled once
self.assertEqual(bundle_mock.call_count, 1)
self.assertEqual(bundle_mock.call_args, mock.call('app/dummy'))

@override_settings(SYSTEMJS_CACHE_DIR=tempfile.mkdtemp())
@mock.patch('systemjs.base.SystemTracer.trace')
def test_minimal_bundle(self, trace_mock, bundle_mock):
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py33-django18,py{27,34,35,py}-django{18,19}
envlist = py33-django18,py{27,34,35,py}-django{18,19,110}
skip_missing_interpreters = true

[testenv]
Expand All @@ -8,5 +8,6 @@ deps =
coveralls
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
commands=
coverage run --rcfile={toxinidir}/.coveragerc {toxinidir}/setup.py test

0 comments on commit c8331d1

Please sign in to comment.