django-systemjs

Overview

Django SystemJS

https://travis-ci.org/sergei-maertens/django-systemjs.svg?branch=master Documentation Status

Django SystemJS brings the Javascript of tomorrow to Django, today.

It leverages JSPM (https://jspm.io) to do the heavy lifting for your client side code, while keeping development flow easy and deployment without worries. In DEBUG mode, your Javascript modules are loaded asynchronously. In production, your app is nicely bundled via JSPM and ties in perfectly with django.contrib.staticfiles.

Installation

Follow the documentation on http://django-systemjs.readthedocs.org/en/latest/.

Comments
  • Optimize bundling

    Optimize bundling

    First of all, great app!

    Maybe I'm doing things the wrong way, but my workflow has been kind of painful. I have several independent .js files that need to be processed. I use ./manage.py systemjs_bundle -e html,jade --minify in production. It works, but there are two problems: The first is that it re-bundles everything, even the files that haven't been modified. Additionally, it seems to go through the entire bundling process again even if I just changed a single character in a file.

    Both issues could probably be solved by simply checking if the files have been modified, although I'm not sure how that would be accomplished. Anyway, it would be something along the lines of jspm --watch in the sense that a cache could be kept to compare differences (just not in "real time").

    If there's already a better way to do that, I would be very thankful to know what it is and you can just ignore my suggestion.

    Thanks for your attention!

    enhancement 
    opened by edjroot 35
  • Development bundle.

    Development bundle.

    The process is explained here http://jspm.io/0.17-beta-guide/development-bundling.html

    It would be great to be able to use it. Libraries like React slow down async module load during development a lot. Maybe we could have some option to enable development bundling, make systemjs_import tag aware of it and load bundle generated by continuously running python manage.py systemjs_bundle in watch mode.

    documentation 
    opened by funn 21
  • Static bundling with Rollup optimization.

    Static bundling with Rollup optimization.

    In jspm 0.17 there is a jspm build command that takes similiar to jspm bundle command and produces bundle without unused code exports. More info here: http://jspm.io/0.17-beta-guide/static-builds-with-rollup-optimization.html What are current plans on supporting this?

    enhancement 
    opened by funn 13
  • Documentation - How to configure jspm

    Documentation - How to configure jspm

    I'm having trouble understanding how to set up jspm to work with this plugin. I've used jspm before but not with Django.

    In the README, it says:

    set the base url to your STATIC_URL. set the base path to your STATIC_ROOT.

    What is the 'base path' referring to, and which 'base url'? From the jspm docs, the configuration options are:

    baseURL: This should be set to the public folder where your server will serve from, relative to the package.json file. Defaults to the package.json folder itself. jspm packages folder: The folder where jspm will install external dependencies. Config file path: The jspm config file for your application. Should be within the baseURL and checked in to version control. Client baseURL: The URL from the browser where the public folder is hosted. Transpiler: Change this option at any time with jspm dl-loader babel. Custom transpilation options can also be set through babelOptions or traceurOptions in the jspm config file.

    It makes sense to set 'client baseURL' to Django's 'STATIC_URL'. However, I don't see how setting 'baseURL' to 'STATIC_ROOT' would be a good idea, as that's where config.js is supposed to go, and my understanding is that the 'STATIC_ROOT' path should not be used for permanently storing any assets.

    I would sincerely appreciate some clarification on this, but also thank you for this interesting project.

    opened by wkevina 10
  • add __init__.py to myapp so it is recognized by django

    add __init__.py to myapp so it is recognized by django

    cloned the examples, tried running and ran into

    Unhandled exception in thread started by <function wrapper at 0x109d277d0>
    Traceback (most recent call last):
      File "/Users/davis/workspace/merlin-admin/opengraph/venv/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
        fn(*args, **kwargs)
      File "/Users/davis/workspace/merlin-admin/opengraph/venv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
        autoreload.raise_last_exception()
      File "/Users/davis/workspace/merlin-admin/opengraph/venv/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
        six.reraise(*_exception)
      File "/Users/davis/workspace/merlin-admin/opengraph/venv/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
        fn(*args, **kwargs)
      File "/Users/davis/workspace/merlin-admin/opengraph/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/Users/davis/workspace/merlin-admin/opengraph/venv/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
        app_config = AppConfig.create(entry)
      File "/Users/davis/workspace/merlin-admin/opengraph/venv/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
        module = import_module(entry)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
    ImportError: No module named myapp
    

    adding init.py solved the problem!

    opened by davis 3
  • bundling multiple times for the same file

    bundling multiple times for the same file

    when there are multiple {% systemjs_import 'my-app.js' %}

    Log shows my-app is being bundled multiple times.

    I think it would be safe to bundle only once for each unique file.

    enhancement 
    opened by pcompassion 3
  • We need automated module loading based on app+view

    We need automated module loading based on app+view

    Import (poor man's) namespaced modules import ProjectSetupView as ProjectProjectSetupView from 'projects/ProjectSetupView';

    Determine the namespaced module based on current app+view

    let app = getApp(),
        view = get View(),
        module = `${app}{view}`;
    
    new module()
    

    The view needs to be know, this can a auto generated mapping or something simple like: <script data-view="balablala">

    enhancement 
    opened by svenvandescheur 3
  • error during bundling

    error during bundling

    Hi,

    I was running into errors trying to bundle the main.js could you let me know what I could be doing wrong?

    Repro:

    git clone [email protected]:sergei-maertens/django-systemjs.git django-systemjs-fork
    cd django-system-fork/example/jspm_0_17
    npm install
    node_modules/jspm/jspm.js install
    node_modules/jspm/jspm.js bundle jspm_0_17/main.js staticfiles/SYSTEMJS/bundles/main.js -wid
    

    Error msg:

    jspm bundle jspm_0_17/main.js staticfiles/SYSTEMJS/bundles/main.js -wid
         Building the bundle tree for jspm_0_17/main.js...
    
    err  Error on fetch for jspm_0_17/main.js at file:///Users/davis/github/django-systemjs-fork/example/jspm_0_17/staticfiles/js/main.js
      Error: ENOENT: no such file or directory, open '/Users/davis/github/django-systemjs-fork/example/jspm_0_17/staticfiles/js/main.js'
        at Error (native)
    
    opened by davis 2
  • Optimization: path matters for trace-deps.js

    Optimization: path matters for trace-deps.js

    It turns out that the node script trace-deps.js only works properly if executed in the folder containing node_modules and package.json. Otherwise, it seems unable to find a config file somewhere.

    This is a jspm thing, need to follow up how to handle this. We could locate package.json and do subprocess.Popen in the containing directory.

    documentation 
    opened by sergei-maertens 1
  • Doesn't work with ManifestStaticFilesStorage

    Doesn't work with ManifestStaticFilesStorage

    This storage collects the static files with a partial md5 hash injected, and then writes the unhashed name -> hashed name mapping to a manifest.json file. This happens in the post-process step.

    Django-SystemJS applies the configured storage post-process, but in a separate step. Each of the two steps first remove the old manifest file and re-create it. So, systemjs_bundle management command causes the result of collectstatic to be undone.

    Solution: subclass the the storage in SystemJS, and before saving the new result, load the old result and append so that the old file is retained. We need to ensure that during a collectstatic run the old file is deleted.

    bug 
    opened by sergei-maertens 1
  • Don't nuke sourcemap comment

    Don't nuke sourcemap comment

    JSPM adds the #SourceMap: /url/to/sourcemap comment after bundling, but our processing doesn't guarantee that it's the last line in the file, which (probably) breaks the functionality.

    This comment should be detected, extracted, and put as the last line of the file.

    enhancement 
    opened by sergei-maertens 1
  • 'NoneType' object has no attribute 'systemjs_bundling'

    'NoneType' object has no attribute 'systemjs_bundling'

    This comes from the following lines in management/commands/systemjs_bundle.py:

            self.storage = copy(staticfiles_storage)
            self.storage.systemjs_bundling = True  # set flag to check later
    

    I'm a pretty good python programmer but I'm not sure what is going on here. The copy() function isn't doing what the original programmer intended ... and the systemjs_bundling attribute is never used so maybe just dispense with that call to copy()?

    BTW, I am using Python 2.7 and Django version 1.8

    bug 
    opened by nmgeek 4
  • Split management command in two commands

    Split management command in two commands

    Reference: https://github.com/sergei-maertens/django-systemjs/issues/28#issuecomment-261618212

    To be able to support all the jspm options, the management command should be split up to match jspm bundle and jspm build.

    enhancement 
    opened by sergei-maertens 0
  • Does not find app level static

    Does not find app level static

    Lets say I have an app web. Inside a template for this app, I load app.js like this {% systemjs_import 'web/app' %}. When in development mode, the system does not have problem finding this static file, but if I do python manage.py systemjs_bundle, it only tries to find this file in the root static directory. I think there should be some sort of namespace, or bundle should try to find the static at app level.

    enhancement question 
    opened by nlhkh 17
  • Investigate 'async' bundling

    Investigate 'async' bundling

    It's possible to fire of subproces.Popen and poll their completion state. When generating multiple bundles, this should be used to parallelize as much as possible.

    This does involve changing the internal API so that the management command doesn't need to know any internals of the polling. The SystemBundle and Tracer classes should expose an uniform API though.

    enhancement 
    opened by sergei-maertens 0
  • shared dependencies

    shared dependencies

    I'd like to exclude jquery, underscore, bootstrap, etc from bundle.

    Those libraries could be bundled seperately as shared dependencies.
    And I believe the following is the jspm's answer to the problem. (I don't get the syntax, hard to find doc explaining what it means excatly :( )

    https://github.com/jspm/jspm-cli/issues/133 https://github.com/jspm/jspm-cli/issues/872 mentions jspm bundle app/**/* - [app/**/*] dependency-bundle.js --inject

    Would it be possible to create a shared dependency bundle with django-systemjs?
    (I'm not even sure the above method would work with django setup because django doesn't have a parent directory such as app)

    enhancement 
    opened by pcompassion 3
Owner
Sergei Maertens
Sergei Maertens
Pipeline is an asset packaging library for Django.

Pipeline Pipeline is an asset packaging library for Django, providing both CSS and JavaScript concatenation and compression, built-in JavaScript templ

Jazzband 1.4k Aug 29, 2021
Transparently use webpack with django

django-webpack-loader Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a detailed step by step guide on setting up webpack with dja

null 2.4k Jan 6, 2023
A django compressor tool that bundles css, js files to a single css, js file with webpack and updates your html files with respective css, js file path.

django-webpacker's documentation: Introduction: django-webpacker is a django compressor tool which bundles css, js files to a single css, js file with

MicroPyramid 72 Aug 18, 2022
Django module to easily send emails/sms/tts/push using django templates stored on database and managed through the Django Admin

Django-Db-Mailer Documentation available at Read the Docs. What's that Django module to easily send emails/push/sms/tts using django templates stored

LPgenerator 250 Dec 21, 2022
Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project

Django URL Shortener Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project Install this package to your Dja

Rishav Sinha 4 Nov 18, 2021
Meta package to combine turbo-django and stimulus-django

Hotwire + Django This repository aims to help you integrate Hotwire with Django ?? Inspiration might be taken from @hotwired/hotwire-rails. We are sti

Hotwire for Django 31 Aug 9, 2022
Django CAS 1.0/2.0/3.0 client authentication library, support Django 2.0, 2.1, 2.2, 3.0 and Python 3.5+

django-cas-ng django-cas-ng is Django CAS (Central Authentication Service) 1.0/2.0/3.0 client library to support SSO (Single Sign On) and Single Logou

django-cas-ng 347 Dec 18, 2022
Django Smuggler is a pluggable application for Django Web Framework that helps you to import/export fixtures via the automatically-generated administration interface.

Django Smuggler Django Smuggler is a pluggable application for Django Web Framework to easily dump/load fixtures via the automatically-generated admin

semente 373 Dec 26, 2022
django-reversion is an extension to the Django web framework that provides version control for model instances.

django-reversion django-reversion is an extension to the Django web framework that provides version control for model instances. Requirements Python 3

Dave Hall 2.8k Jan 2, 2023
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.7k Jan 7, 2023
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 909 Dec 26, 2022
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Feldroy 10k Dec 31, 2022
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App ?? We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022
Django Ninja - Fast Django REST Framework

Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

Vitaliy Kucheryaviy 3.8k Jan 2, 2023
Chat app for Django, powered by Django Channels, Websockets & Asyncio

Django Private Chat2 New and improved https://github.com/Bearle/django-private-chat Chat app for Django, powered by Django Channels, Websockets & Asyn

Bearle 205 Dec 30, 2022
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.7k Jan 3, 2023
django-quill-editor makes Quill.js easy to use on Django Forms and admin sites

django-quill-editor django-quill-editor makes Quill.js easy to use on Django Forms and admin sites No configuration required for static files! The ent

lhy 139 Dec 5, 2022
Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

?? Fast, Async-ready, Openapi, type hints based framework for building APIs

Vitaliy Kucheryaviy 3.8k Jan 4, 2023
A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, celery and redis.

Django Channels Websocket Chatbot A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, c

Yunbo Shi 8 Oct 28, 2022
A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.

Django Sage Painless The django-sage-painless is a valuable package based on Django Web Framework & Django Rest Framework for high-level and rapid web

sageteam 51 Sep 15, 2022