mcculloughsean / emport Goto Github PK
View Code? Open in Web Editor NEWThis project forked from quackingduck-archive/emport
A module-like packaging system for js and coffee that should run in the browser
This project forked from quackingduck-archive/emport
A module-like packaging system for js and coffee that should run in the browser
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.