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']
|
||||
},
|
||||
|
||||
copy: {
|
||||
includereplace: {
|
||||
options: {
|
||||
prefix: '// @@',
|
||||
},
|
||||
main: {
|
||||
expand: true,
|
||||
src: ['<%= paths.srcFolder %>/Layout.js'],
|
||||
dest: '<%= paths.distFolder %>',
|
||||
rename: function(dest, src) {
|
||||
return dest + '/css-layout.js';
|
||||
}
|
||||
// Files to perform replacements and includes with
|
||||
src: '<%= paths.srcFolder %>/css-layout.js',
|
||||
// Destination directory to copy files to
|
||||
dest: '<%= paths.distFolder %>/css-layout.js'
|
||||
}
|
||||
},
|
||||
|
||||
@@ -39,7 +40,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
main: {
|
||||
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']);
|
||||
};
|
||||
|
@@ -20,6 +20,7 @@
|
||||
"grunt-contrib-copy": "^0.8.0",
|
||||
"grunt-contrib-uglify": "^0.9.1",
|
||||
"grunt-eslint": "^17.1.0",
|
||||
"grunt-include-replace": "^3.1.0",
|
||||
"grunt-karma": "^0.12.0",
|
||||
"jasmine-core": "^2.2.0",
|
||||
"karma": "^0.13.8",
|
||||
|
@@ -11,14 +11,15 @@
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.returnExports = factory();
|
||||
root.computeLayout = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
var layout = require('./Layout.js');
|
||||
// @@include('./Layout.js')
|
||||
|
||||
return function(node) {
|
||||
node = layout.fillNodes(node);
|
||||
layout.computeLayout(node);
|
||||
node = layout.extractNodes(node);
|
||||
node = computeLayout.fillNodes(node);
|
||||
computeLayout.computeLayout(node);
|
||||
node = computeLayout.extractNodes(node);
|
||||
return node;
|
||||
};
|
||||
}));
|
Reference in New Issue
Block a user