forked from ractivejs/ractive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gobblefile.js
90 lines (78 loc) · 2.14 KB
/
gobblefile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var gobble = require( 'gobble' ),
sander = require( 'sander' ),
src = gobble( 'src' ),
sandbox = gobble( 'sandbox' ).moveTo( 'sandbox' ),
version = require( './package.json' ).version,
banner,
bundleTransform,
es5, result;
// This is necessary until this gets merged, or 6to5 gets fixed:
// https://github.com/termi/es6-transpiler/pull/73
require( 'es6-transpiler' );
require( 'gobble-es6-transpiler' );
Object.defineProperty( Array.prototype, 'contains', { enumerable: false });
Object.defineProperty( String.prototype, 'contains', { enumerable: false });
banner = sander.readFileSync( __dirname, 'src/banner.js' ).toString()
.replace( '${version}', version )
.replace( '${time}', new Date() )
.replace( '${commitHash}', process.env.COMMIT_HASH || 'unknown' );
bundleTransform = function ( src, path ) {
if ( /Ractive\.js$/.test( path ) ) {
return src.replace( '${version}', version );
}
return src;
};
es5 = src.transform( '6to5', { blacklist: [ 'modules', 'useStrict' ]});
result = [
es5.transform( 'esperanto-bundle', {
type: 'umd',
transform: bundleTransform,
banner: banner,
entry: 'Ractive.js',
name: 'Ractive',
dest: 'ractive-legacy.js'
})
];
if ( gobble.env() === 'production' ) {
// Add non-legacy and runtime-only builds
result.push(
es5.transform( 'esperanto-bundle', {
type: 'umd',
transform: bundleTransform,
banner: banner,
entry: 'Ractive.js',
name: 'Ractive',
dest: 'ractive.js',
skip: [ 'legacy' ]
}),
es5.transform( 'esperanto-bundle', {
type: 'umd',
transform: bundleTransform,
banner: banner,
entry: 'Ractive.js',
name: 'Ractive',
dest: 'ractive.runtime.js',
skip: [ 'legacy', 'parse/_parse' ]
}),
es5.transform( 'esperanto-bundle', {
type: 'umd',
transform: bundleTransform,
banner: banner,
entry: 'Ractive.js',
name: 'Ractive',
dest: 'ractive-legacy.runtime.js',
skip: [ 'parse/_parse' ]
})
);
// TODO sourcemaps are currently pooched. Investigating...
/*result = result.map( function ( node ) {
return node.transform( 'sorcery' );
});*/
}
else {
result.push( sandbox );
}
module.exports = gobble([
result,
require( './test/gobblefile' )
]);