-
Notifications
You must be signed in to change notification settings - Fork 224
[WIP] - Switch to Rollup #895
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,30 +15,6 @@ banner = """ | |
|
|
||
| """ | ||
|
|
||
| umdHead = ''' | ||
| (function(root, factory) { | ||
| if (typeof define === 'function' && define.amd) { | ||
| define(['backbone', 'underscore'], factory); | ||
| } else if (typeof module === 'object' && module && module.exports) { | ||
| module.exports = factory(require('backbone'), require('underscore')); | ||
| } else if (typeof require === 'function') { | ||
| factory(window.Backbone, window._ || window.Backbone.utils); | ||
| } else { | ||
| throw new Error('Chaplin requires Common.js or AMD modules'); | ||
| } | ||
| }(this, function(Backbone, _) { | ||
| function require(name) { | ||
| return {backbone: Backbone, underscore: _}[name]; | ||
| } | ||
|
|
||
| require = | ||
| ''' | ||
|
|
||
| umdTail = ''' | ||
| return require(1); | ||
| })) | ||
| ''' | ||
|
|
||
| module.exports = (grunt) -> | ||
|
|
||
| # Configuration | ||
|
|
@@ -56,51 +32,63 @@ module.exports = (grunt) -> | |
| options: | ||
| configFile: 'coffeelint.json' | ||
|
|
||
| clean: ['./tmp'] | ||
|
|
||
| coffee: | ||
| test: | ||
| expand: true, | ||
| cwd: './test/', | ||
| src: ['*.coffee'], | ||
| dest: './tmp/test/', | ||
| ext: '.js' | ||
|
|
||
| mochaTest: | ||
| native: | ||
| options: | ||
| reporter: 'spec' | ||
| require: [ | ||
| 'coffee-script/register' | ||
| 'coffee-coverage/register-istanbul' | ||
| -> | ||
| global._$coffeeIstanbul = {} | ||
| 'babel-register' | ||
| 'jsdom-assign' | ||
| -> require.cache[require.resolve 'jquery'] = {} | ||
| 'backbone.nativeview' | ||
| ] | ||
| src: 'test/*.coffee' | ||
| src: 'tmp/test/*.js' | ||
| jquery: | ||
| options: | ||
| reporter: 'spec' | ||
| require: [ | ||
| 'coffee-script/register' | ||
| -> | ||
| global._$coffeeIstanbul = {} | ||
| 'babel-register' | ||
| 'jsdom-assign' | ||
| ] | ||
| src: 'test/*.coffee' | ||
| src: 'tmp/test/*.js' | ||
|
|
||
| makeReport: | ||
| src: 'coverage/coverage-coffee.json', | ||
| options: | ||
| type: 'html' | ||
| dir: 'coverage' | ||
|
|
||
| browserify: | ||
| rollup: | ||
| options: | ||
| plugins: [ | ||
| require('rollup-plugin-coffee-script')() | ||
| require('rollup-plugin-node-resolve')(extensions: ['.coffee']) | ||
| ] | ||
| external: ['underscore', 'backbone'] | ||
| globals: | ||
| backbone: 'Backbone' | ||
| underscore: '_' | ||
| format: 'umd' | ||
| moduleName: 'Chaplin' | ||
| banner: banner | ||
|
|
||
| dist: | ||
| files: | ||
| 'build/chaplin.js': ['./src/chaplin.coffee'] | ||
| options: { | ||
| banner | ||
| external: ['backbone', 'underscore'] | ||
| transform: ['coffeeify'] | ||
| browserifyOptions: | ||
| debug: true | ||
| extensions: ['.coffee'] | ||
| postBundleCB: (err, src, next) -> | ||
| if err | ||
| next err | ||
| else | ||
| src = umdHead + src + umdTail | ||
| next null, new Buffer src | ||
| } | ||
| 'build/chaplin.js': 'src/chaplin.coffee' | ||
|
|
||
| # Minify | ||
| # ====== | ||
|
|
@@ -298,17 +286,25 @@ module.exports = (grunt) -> | |
|
|
||
| # Tests | ||
| # ===== | ||
|
|
||
| grunt.registerTask 'instrument', -> | ||
| {CoverageInstrumentor} = require('coffee-coverage') | ||
| coverageInstrumentor = new CoverageInstrumentor({ | ||
| instrumentor: 'istanbul' | ||
| }) | ||
| coverageInstrumentor.instrument('./src', './tmp/src', bare: true) | ||
|
|
||
| grunt.registerTask 'lint', 'coffeelint' | ||
| grunt.registerTask 'test', 'mochaTest:native' | ||
| grunt.registerTask 'test:jquery', 'mochaTest:jquery' | ||
| grunt.registerTask 'test', ['clean', 'instrument', 'coffee:test', 'mochaTest:native'] | ||
| grunt.registerTask 'test:jquery', ['clean', 'instrument', 'coffee:test', 'mochaTest:jquery'] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part need some rework. |
||
|
|
||
| # Coverage | ||
| # ======== | ||
| grunt.registerTask 'coverage', ['mochaTest:native', 'makeReport'] | ||
|
|
||
| # Building | ||
| # ======== | ||
| grunt.registerTask 'build', ['browserify', 'uglify', 'compress'] | ||
| grunt.registerTask 'build', ['rollup', 'uglify', 'compress'] | ||
|
|
||
| # Default | ||
| # ======= | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,30 +4,35 @@ | |
| "description": "An Application Architecture Using Backbone.js", | ||
| "repository": "git://github.com/chaplinjs/chaplin.git", | ||
| "dependencies": { | ||
| "babel-register": "6.18.0", | ||
| "backbone": "~1.3.3", | ||
| "underscore": "~1.8.3" | ||
| }, | ||
| "devDependencies": { | ||
| "babel-plugin-transform-es2015-modules-commonjs": "6.18.0", | ||
| "backbone.nativeview": "~0.3.3", | ||
| "chai": "3.5.x", | ||
| "coffee-coverage": "1.0.1", | ||
| "coffee-script": "1.10.x", | ||
| "coffeeify": "~2.0.1", | ||
| "coffee-script": "1.11.x", | ||
| "grunt": "~0.4.5", | ||
| "grunt-browserify": "~4.0.1", | ||
| "grunt-cli": "~0.1.13", | ||
| "grunt-coffeelint": "~0.0.15", | ||
| "grunt-contrib-clean": "1.0.0", | ||
| "grunt-contrib-coffee": "florian-r/grunt-contrib-coffee", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is WIP pending a new release of |
||
| "grunt-contrib-compress": "0.14.x", | ||
| "grunt-contrib-uglify": "~0.11.1", | ||
| "grunt-contrib-watch": "~0.6.1", | ||
| "grunt-istanbul": "0.7.0", | ||
| "grunt-mocha-test": "~0.12.7", | ||
| "grunt-rollup": "1.0.1", | ||
| "grunt-transbrute": "0.2.x", | ||
| "jquery": "2.2.x", | ||
| "jsdom": "~8.0.2", | ||
| "jsdom-assign": "shvaikalesh/jsdom-assign", | ||
| "mocha": "~2.4.5", | ||
| "prompt": "~0.2.14", | ||
| "rollup-plugin-coffee-script": "1.1.0", | ||
| "rollup-plugin-node-resolve": "2.0.0", | ||
| "sinon": "~1.17.3", | ||
| "sinon-chai": "2.8.x" | ||
| }, | ||
|
|
@@ -37,5 +42,10 @@ | |
| "coverage": "grunt coverage", | ||
| "build": "grunt build" | ||
| }, | ||
| "license": "SEE LICENSE IN MIT-LICENSE.txt" | ||
| "license": "SEE LICENSE IN MIT-LICENSE.txt", | ||
| "babel": { | ||
| "plugins": [ | ||
| "transform-es2015-modules-commonjs" | ||
| ] | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inlined this to avoid a .babelrc |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,41 @@ | ||
| 'use strict' | ||
| import Application from './chaplin/application' | ||
| import Composer from './chaplin/composer' | ||
| import Controller from './chaplin/controllers/controller' | ||
| import Dispatcher from './chaplin/dispatcher' | ||
| import Composition from './chaplin/lib/composition' | ||
| import EventBroker from './chaplin/lib/event_broker' | ||
| import History from './chaplin/lib/history' | ||
| import Route from './chaplin/lib/route' | ||
| import Router from './chaplin/lib/router' | ||
| import support from './chaplin/lib/support' | ||
| import SyncMachine from './chaplin/lib/sync_machine' | ||
| import utils from './chaplin/lib/utils' | ||
| import mediator from './chaplin/mediator' | ||
| import Collection from './chaplin/models/collection' | ||
| import Model from './chaplin/models/model' | ||
| import CollectionView from './chaplin/views/collection_view' | ||
| import Layout from './chaplin/views/layout' | ||
| import View from './chaplin/views/view' | ||
|
|
||
| # Main entry point into Chaplin module. | ||
| # Load all components and expose them. | ||
| module.exports = | ||
| Application: require './chaplin/application' | ||
| Composer: require './chaplin/composer' | ||
| Controller: require './chaplin/controllers/controller' | ||
| Dispatcher: require './chaplin/dispatcher' | ||
| Composition: require './chaplin/lib/composition' | ||
| EventBroker: require './chaplin/lib/event_broker' | ||
| History: require './chaplin/lib/history' | ||
| Route: require './chaplin/lib/route' | ||
| Router: require './chaplin/lib/router' | ||
| support: require './chaplin/lib/support' | ||
| SyncMachine: require './chaplin/lib/sync_machine' | ||
| utils: require './chaplin/lib/utils' | ||
| mediator: require './chaplin/mediator' | ||
| Collection: require './chaplin/models/collection' | ||
| Model: require './chaplin/models/model' | ||
| CollectionView: require './chaplin/views/collection_view' | ||
| Layout: require './chaplin/views/layout' | ||
| View: require './chaplin/views/view' | ||
| export default { | ||
| Application | ||
| Composer | ||
| Controller | ||
| Dispatcher | ||
| Composition | ||
| EventBroker | ||
| History | ||
| Route | ||
| Router | ||
| support | ||
| SyncMachine | ||
| utils | ||
| mediator | ||
| Collection | ||
| Model | ||
| CollectionView | ||
| Layout | ||
| View | ||
| } | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ugly, but needed.
istanbuladd something likein every modules. This breaks badly with
babel-registerwhich wrap the code in a function with ause strictpragma.Edit: In all fairness, this comes indeed from
coffee-coverage. I've proposed a fix here benbria/coffee-coverage#82 (comment)