Giter VIP home page Giter VIP logo

emport's Introduction

                               emport.js

  A module-like packaging system for javascript and coffeescript source files
  that target the browser.

  This is an early beta release. Use at your own risk etc. See /examples
  folder for usage example.

                                  ---

Hey what about requirejs(.org) and AMD? Have you heard about those?! They do
the thing that this thing does!

  emport.js makes some different tradeoffs from require.js, from reading
  http://requirejs.org/docs/why.html, we are in agreement with everything up
  until "First thing to sort out is a script loading API"
  
  emport.js is the result of asking "what if we ditch the script loading
  API?". We still want our individual javascript files to look like modules.
  At the top of the file we want to see the interface the module exports and
  what other modules it depends on. Those are good things. And it's obviously
  a good idea to use that information to generate the Giant Concatenated
  Source String that gets sent to down to browsers. But other than that it
  should be browser-side programming just like the old days with our old
  friend:
  
    (function(){
      
      this.MyModuleName = function() ...
      
    }).call(this);

  ... he's done good by us. Coffeescript users don't even have to type the
  closure because coffeescript is javascript's best friend.


What does it look like?

  Here is an example (coffeescript) source file header pulled from an app
  running in production that shows what using emport.js looks like in
  practice:
  
    #@export GoalListView

    #@import Backbone
    #@import $
    #@import $.fn.chosen
    #@import $.fn.sortable
    #@import records
    #@import goalListItemView

    class @GoalListView extends Backbone.View
      ... class implementation ...
  
  As you can see the import and export directives are just comments with a
  specific syntax. If you decide to give up on modularizing your client-side
  js and just go back to The Way It Was then nothing will break. You just
  delete the comments and your code is exactly how it used to be.


Does emport.js throw an error when a module tries to access a global variable
it has not imported?

  Currently no, but that seems like the right direction to head.


Why would I want to put all these stupid boilerplate import and export
comments everywhere?! This just seems like extra work! Haven't you used Ruby
on Rails? What's wrong with just assuming that every source file has access to
all the rest of the code in the project automatically?

  Yes. Modularization at the source file level is not every developer's cup of
  tea.

                                  ---

Some other projects that occupy the same general vicinity as emport.js that
you may also be interested in:

  r.js - node.js based library and command line tool for packaging js source
  files that use the requirejs module system
  https://github.com/jrburke/r.js

  Sprockets - Rack (Ruby) based, does dependency-aware concatenation of js
  source files and many other things too. Built into Rails 3.1
  https://github.com/sstephenson/sprockets

emport's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.