Module pattern is now implemented via templating
Previously two modules were defined, Layout.js, which is the internal implementation, and main.js, which depended on Layout.js and performed the fill / extract functionality required for a public JavaScript API. This simplifies the implementation by just exposing a single UMD module by directly including Layout.js within the module wrapper. Fixes #103
This commit is contained in:
19
Gruntfile.js
19
Gruntfile.js
@@ -21,14 +21,15 @@ module.exports = function(grunt) {
|
|||||||
target: ['<%= paths.srcFolder %>/Layout.js']
|
target: ['<%= paths.srcFolder %>/Layout.js']
|
||||||
},
|
},
|
||||||
|
|
||||||
copy: {
|
includereplace: {
|
||||||
|
options: {
|
||||||
|
prefix: '// @@',
|
||||||
|
},
|
||||||
main: {
|
main: {
|
||||||
expand: true,
|
// Files to perform replacements and includes with
|
||||||
src: ['<%= paths.srcFolder %>/Layout.js'],
|
src: '<%= paths.srcFolder %>/css-layout.js',
|
||||||
dest: '<%= paths.distFolder %>',
|
// Destination directory to copy files to
|
||||||
rename: function(dest, src) {
|
dest: '<%= paths.distFolder %>/css-layout.js'
|
||||||
return dest + '/css-layout.js';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
main: {
|
main: {
|
||||||
files: {
|
files: {
|
||||||
'<%= paths.distFolder %>/css-layout.min.js': ['<%= paths.srcFolder %>/Layout.js']
|
'<%= paths.distFolder %>/css-layout.min.js': ['<%= paths.distFolder %>/css-layout.js']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -61,7 +62,7 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('build', ['eslint', 'clean', 'karma' ,'copy', 'uglify']);
|
grunt.registerTask('build', ['eslint', 'clean', 'karma' ,'includereplace', 'uglify']);
|
||||||
|
|
||||||
grunt.registerTask('default', ['build']);
|
grunt.registerTask('default', ['build']);
|
||||||
};
|
};
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
"grunt-contrib-copy": "^0.8.0",
|
"grunt-contrib-copy": "^0.8.0",
|
||||||
"grunt-contrib-uglify": "^0.9.1",
|
"grunt-contrib-uglify": "^0.9.1",
|
||||||
"grunt-eslint": "^17.1.0",
|
"grunt-eslint": "^17.1.0",
|
||||||
|
"grunt-include-replace": "^3.1.0",
|
||||||
"grunt-karma": "^0.12.0",
|
"grunt-karma": "^0.12.0",
|
||||||
"jasmine-core": "^2.2.0",
|
"jasmine-core": "^2.2.0",
|
||||||
"karma": "^0.13.8",
|
"karma": "^0.13.8",
|
||||||
|
@@ -11,14 +11,15 @@
|
|||||||
module.exports = factory();
|
module.exports = factory();
|
||||||
} else {
|
} else {
|
||||||
// Browser globals (root is window)
|
// Browser globals (root is window)
|
||||||
root.returnExports = factory();
|
root.computeLayout = factory();
|
||||||
}
|
}
|
||||||
}(this, function () {
|
}(this, function () {
|
||||||
var layout = require('./Layout.js');
|
// @@include('./Layout.js')
|
||||||
|
|
||||||
return function(node) {
|
return function(node) {
|
||||||
node = layout.fillNodes(node);
|
node = computeLayout.fillNodes(node);
|
||||||
layout.computeLayout(node);
|
computeLayout.computeLayout(node);
|
||||||
node = layout.extractNodes(node);
|
node = computeLayout.extractNodes(node);
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
}));
|
}));
|
Reference in New Issue
Block a user