feat(bower): use exposify to build bower bundle
This commit uses exposify to perform a quick replace on web dependency require() statements before browserify can process them. This way we access our external dependencies (jquery, lodash, snapsvg, sax) via window globals in a standalone bower bundle. Closes #63
This commit is contained in:
parent
fc45cf8c61
commit
42b14c97e2
27
Gruntfile.js
27
Gruntfile.js
|
@ -127,6 +127,33 @@ module.exports = function(grunt) {
|
|||
])
|
||||
}
|
||||
},
|
||||
bowerViewer: {
|
||||
files: {
|
||||
'../bower-bpmn-js/bpmn-viewer.js': [ '<%= config.sources %>/lib/Viewer.js' ]
|
||||
},
|
||||
options: {
|
||||
bundleOptions: {
|
||||
detectGlobals: false,
|
||||
insertGlobalVars: [],
|
||||
debug: false
|
||||
},
|
||||
transform: [
|
||||
[ 'exposify', {
|
||||
expose: {
|
||||
sax: 'sax',
|
||||
snapsvg: 'Snap',
|
||||
lodash: '_',
|
||||
jquery: '$',
|
||||
'jquery-mousewheel': '$'
|
||||
}
|
||||
} ]
|
||||
],
|
||||
alias: bundleAlias([
|
||||
'viewer',
|
||||
'libs-local'
|
||||
])
|
||||
}
|
||||
},
|
||||
standaloneViewer: {
|
||||
files: {
|
||||
'<%= config.dist %>/bpmn-viewer.js': [ '<%= config.sources %>/lib/Viewer.js' ]
|
||||
|
|
26
bower.json
26
bower.json
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"name": "bpmn-js",
|
||||
"version": "0.0.1",
|
||||
"authors": [
|
||||
"bpmn.io"
|
||||
],
|
||||
"description": "A bpmn 2.0 toolkit and web modeler",
|
||||
"main": "dist/bpmn.js",
|
||||
"keywords": [
|
||||
"models",
|
||||
"diagram",
|
||||
"renderer",
|
||||
"modeler"
|
||||
],
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"homepage": "http://bpmn.io",
|
||||
"private": true,
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test"
|
||||
]
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
var $ = require('jquery');
|
||||
|
||||
var mousewheel = require('jquery-mousewheel');
|
||||
if (mousewheel !== $ && !$.mousewheel) { mousewheel($); }
|
||||
|
||||
|
||||
function ZoomScroll(events, canvas) {
|
||||
|
@ -29,7 +32,7 @@ function ZoomScroll(events, canvas) {
|
|||
|
||||
function init(element) {
|
||||
|
||||
mousewheel(element).on('mousewheel', function(event) {
|
||||
$(element).on('mousewheel', function(event) {
|
||||
|
||||
var shift = event.shiftKey,
|
||||
ctrl = event.ctrlKey;
|
||||
|
|
37
package.json
37
package.json
|
@ -29,29 +29,29 @@
|
|||
],
|
||||
"license": "http://bpmn.io/license",
|
||||
"devDependencies": {
|
||||
"brfs": "~1.0.0",
|
||||
"exposify": "https://github.com/Nikku/exposify/archive/v0.2.0-transform-arguments-0.tar.gz",
|
||||
"grunt": "~0.4.4",
|
||||
"grunt-contrib-watch": "~0.5.0",
|
||||
"grunt-contrib-connect": "~0.6.0",
|
||||
"grunt-contrib-jshint": "~0.7.2",
|
||||
"grunt-contrib-copy": "~0.5.0",
|
||||
"grunt-contrib-uglify": "~0.4.0",
|
||||
"grunt-browserify": "~2.1.0",
|
||||
"grunt-contrib-connect": "~0.6.0",
|
||||
"grunt-contrib-copy": "~0.5.0",
|
||||
"grunt-contrib-jshint": "~0.7.2",
|
||||
"grunt-contrib-uglify": "~0.4.0",
|
||||
"grunt-contrib-watch": "~0.5.0",
|
||||
"grunt-jasmine-node": "~0.2.1",
|
||||
"grunt-jsdoc": "~0.5.1",
|
||||
"grunt-karma": "~0.8.0",
|
||||
"grunt-jasmine-node": "~0.2.1",
|
||||
"grunt-release": "~0.7.0",
|
||||
"load-grunt-tasks": "~0.3.0",
|
||||
"time-grunt": "~0.3.0",
|
||||
"jsondiffpatch": "^0.1.7",
|
||||
"karma": "~0.12.8",
|
||||
"karma-jasmine": "https://github.com/Nikku/karma-jasmine/archive/jasmine-v2.0.0-latest-1.tar.gz",
|
||||
"karma-chrome-launcher": "~0.1.2",
|
||||
"karma-phantomjs-launcher": "0.1.2",
|
||||
"karma-ie-launcher": "~0.1.4",
|
||||
"karma-firefox-launcher": "~0.1.3",
|
||||
"karma-bro": "~0.2.0",
|
||||
"jsondiffpatch": "~0.1.4",
|
||||
"brfs": "~1.0.0",
|
||||
"through": "~2.3.4"
|
||||
"karma-chrome-launcher": "~0.1.2",
|
||||
"karma-firefox-launcher": "~0.1.3",
|
||||
"karma-ie-launcher": "~0.1.4",
|
||||
"karma-jasmine": "https://github.com/Nikku/karma-jasmine/archive/jasmine-v2.0.0-latest-1.tar.gz",
|
||||
"karma-phantomjs-launcher": "0.1.2",
|
||||
"load-grunt-tasks": "~0.3.0",
|
||||
"time-grunt": "~0.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bpmn-moddle": "~0.0.1",
|
||||
|
@ -61,10 +61,5 @@
|
|||
"jquery": "~2.1.0",
|
||||
"jquery-mousewheel": "~3.1.11",
|
||||
"lodash": "~2.4.0"
|
||||
},
|
||||
"browser": {
|
||||
"lodash": "./vendor/lodash.js",
|
||||
"jquery": "./vendor/jquery.js",
|
||||
"jquery-mousewheel": "./vendor/jquery-mousewheel.js"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var $;
|
||||
|
||||
if (!window.$) {
|
||||
$ = require('jquery');
|
||||
require('../node_modules/jquery-mousewheel')($);
|
||||
}
|
||||
|
||||
module.exports = window.$ || $;
|
|
@ -1 +0,0 @@
|
|||
module.exports = window.$ || require('../node_modules/jquery');
|
|
@ -1 +0,0 @@
|
|||
module.exports = window._ || require('../node_modules/lodash');
|
Loading…
Reference in New Issue