Improve module support

This commit is contained in:
Kevin MacMartin 2017-11-13 21:00:00 -05:00
parent ceb72b0e13
commit aee18dc3b2
5 changed files with 32 additions and 9 deletions

View file

@ -1,4 +1,4 @@
function ContainElement(options) { module.exports = function(options) {
var scaleFactor = 1, var scaleFactor = 1,
element = options.element || document.getElementById(options.id), element = options.element || document.getElementById(options.id),
elementWidth = options.width || element.offsetWidth, elementWidth = options.width || element.offsetWidth,
@ -144,6 +144,4 @@ function ContainElement(options) {
// External function to return the current scale factor // External function to return the current scale factor
this.getScale = function() { return scaleFactor; }; this.getScale = function() { return scaleFactor; };
} };
export default ContainElement;

View file

@ -1,9 +1,15 @@
const gulp = require("gulp"), const gulp = require("gulp"),
ugly = require("gulp-uglify"), ugly = require("gulp-uglify"),
concat = require("gulp-concat"); concat = require("gulp-concat"),
insert = require("gulp-insert");
gulp.task("module", function() { gulp.task("module", function() {
return gulp.src([ "contain-element.js", "module-template.js" ]) return gulp.src([ "contain-element.js" ])
.pipe(insert.transform(function(contents) {
return contents
.replace(/^function ContainElement/, "module.exports = function")
.replace(/\n\}/, "\n};");
}))
.pipe(concat("contain-element-module.js")) .pipe(concat("contain-element-module.js"))
.pipe(gulp.dest("./")); .pipe(gulp.dest("./"));
}); });

View file

@ -1 +0,0 @@
export default ContainElement;

21
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "contain-element", "name": "contain-element",
"version": "1.6.2", "version": "1.6.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -617,6 +617,16 @@
} }
} }
}, },
"gulp-insert": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/gulp-insert/-/gulp-insert-0.5.0.tgz",
"integrity": "sha1-MjE/E+SiPPWsylzl8MCAkjx3hgI=",
"dev": true,
"requires": {
"readable-stream": "1.1.14",
"streamqueue": "0.0.6"
}
},
"gulp-uglify": { "gulp-uglify": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-3.0.0.tgz", "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-3.0.0.tgz",
@ -1463,6 +1473,15 @@
"integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=",
"dev": true "dev": true
}, },
"streamqueue": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/streamqueue/-/streamqueue-0.0.6.tgz",
"integrity": "sha1-ZvX17JTpuK8knkrsLdH3Qb/pTeM=",
"dev": true,
"requires": {
"readable-stream": "1.1.14"
}
},
"string_decoder": { "string_decoder": {
"version": "0.10.31", "version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",

View file

@ -1,7 +1,7 @@
{ {
"name": "contain-element", "name": "contain-element",
"description": "A JavaScript plugin to contain an element within its parent element.", "description": "A JavaScript plugin to contain an element within its parent element.",
"version": "1.6.3", "version": "1.6.4",
"license": "MIT", "license": "MIT",
"main": "contain-element.min.js", "main": "contain-element.min.js",
"homepage": "https://github.com/WilliamsNY/contain-element", "homepage": "https://github.com/WilliamsNY/contain-element",
@ -40,6 +40,7 @@
"devDependencies": { "devDependencies": {
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-insert": "^0.5.0",
"gulp-uglify": "^3.0.0" "gulp-uglify": "^3.0.0"
}, },
"scripts": { "scripts": {