{"id":16773829,"url":"https://github.com/ziflex/gulp-module-wrapper","last_synced_at":"2025-03-16T17:21:29.829Z","repository":{"id":25002171,"uuid":"28421166","full_name":"ziflex/gulp-module-wrapper","owner":"ziflex","description":"Module wrapper","archived":false,"fork":false,"pushed_at":"2017-06-26T16:43:39.000Z","size":64,"stargazers_count":0,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T04:14:44.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ziflex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-23T21:45:36.000Z","updated_at":"2017-06-20T18:18:34.000Z","dependencies_parsed_at":"2022-08-25T21:23:42.095Z","dependency_job_id":null,"html_url":"https://github.com/ziflex/gulp-module-wrapper","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fgulp-module-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fgulp-module-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fgulp-module-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fgulp-module-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziflex","download_url":"https://codeload.github.com/ziflex/gulp-module-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243903166,"owners_count":20366434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T06:47:09.114Z","updated_at":"2025-03-16T17:21:29.809Z","avatar_url":"https://github.com/ziflex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Information\r\n\r\n\u003ctable\u003e\r\n\u003ctr\u003e\r\n\u003ctd\u003ePackage\u003c/td\u003e\u003ctd\u003egulp-module-wrapper\u003c/td\u003e\r\n\u003c/tr\u003e\r\n\u003ctr\u003e\r\n\u003ctd\u003eDescription\u003c/td\u003e\r\n\u003ctd\u003eProcesses files to create AMD/UMD/CommonJS modules\u003c/td\u003e\r\n\u003c/tr\u003e\r\n\u003ctr\u003e\r\n\u003ctd\u003eNode Version\u003c/td\u003e\r\n\u003ctd\u003e≥ 0.10\u003c/td\u003e\r\n\u003c/tr\u003e\r\n\u003c/table\u003e\r\n\r\n[![npm version](https://badge.fury.io/js/gulp-module-wrapper.svg)](https://www.npmjs.com/package/gulp-module-wrapper)\r\n[![Build Status](https://secure.travis-ci.org/ziflex/pinterval.svg?branch=master)](http://travis-ci.org/ziflex/pinterval)\r\n\r\n## Basic Usage\r\n\r\nProcesses the content of the file, module will return the entire content  \r\n\r\n```javascript\r\nvar wrapper = require('gulp-module-wrapper');\r\n\r\ngulp.task('wrap', function() {\r\n  gulp.src('./lib/*.js')\r\n    .pipe(wrapper())\r\n    .pipe(gulp.dest('./dist/'))\r\n});\r\n```\r\n\r\nProcess the contents, with custom dependencies, callback params, and variable to return (exports)  \r\n\r\n```javascript\r\nvar wrapper = require('gulp-module-wrapper');\r\n\r\ngulp.task('wrap', function() {\r\n  gulp.src('./lib/*.js')\r\n    .pipe(wrapper({\r\n      deps: ['jade'],          // module's dependencies\r\n      args: ['jade'],          // module's arguments\r\n      exports: 'jade',         // variable to return\r\n      root: 'templates/'       // include a module name in the define() call, relative to moduleRoot\r\n    }))\r\n    .pipe(gulp.dest('./dist/'))\r\n});\r\n```\r\n\r\nThe same but for specific files  \r\n\r\n```javascript\r\nvar wrapper = require('gulp-module-wrapper');\r\nvar options = {\r\n  'app.js' : {\r\n    'name' : 'app'        // allowed to specify module name, otherwise filename will be used\r\n    'deps' : ['router'],\r\n    'args' : ['appRouter'],\r\n    'exports' : 'app'\r\n  },\r\n  'router.js' : {\r\n      'name' : 'router'\r\n      'exports' : 'router'\r\n    }\r\n};\r\n\r\ngulp.task('wrap', function() {\r\n  gulp.src('./lib/*.js')\r\n    .pipe(wrapper(options))\r\n    .pipe(gulp.dest('./dist/'))\r\n});\r\n```\r\n\r\nIgnore files, for example, your AMD loader  \r\n\r\n```javascript\r\nvar wrapper = require('gulp-module-wrapper');\r\n\r\ngulp.task('wrap', function() {\r\n  gulp.src('./lib/*.js')\r\n    .pipe(wrapper({}, ['**/require.js']))\r\n    .pipe(gulp.dest('./dist/'))\r\n});\r\n```\r\n\r\nor matched by pattern  \r\n\r\n```javascript\r\nvar wrapper = require('gulp-module-wrapper');\r\n\r\ngulp.task('wrap', function() {\r\n  gulp.src('./lib/*.js')\r\n    .pipe(wrapper({}, ['**/*.js']))\r\n    .pipe(gulp.dest('./dist/'))\r\n});\r\n```\r\nFor more information look [here](https://github.com/robrich/gulp-match/blob/master/README.md)  \r\n\r\nAll modules will get default dependencies like 'exports', 'require', 'module'.  \r\nIf module root is not specified, filename will be used for module's name.  \r\n\r\n### Module type\r\n\r\n``gulp-module-wrapper`` supports different module types: ``amd``, ``umd``, ``commonjs``\r\nTo selected required module type just passe the option ``type``:  \r\n\r\n```javascript\r\nvar wrapper = require('gulp-module-wrapper');\r\n\r\ngulp.task('wrap', function() {\r\n  gulp.src('./lib/*.js')\r\n    .pipe(wrapper({\r\n      type: 'umd'\r\n    }))\r\n    .pipe(gulp.dest('./dist/'))\r\n});\r\n```\r\n\r\n``amd`` is used by default.  \r\n\r\n\r\n### Dependencies\r\n#### Commonjs\r\n\r\nSine v0.3.8 there is a way to define sub module dependencies like ````'jade.runtime'````:\r\n\r\n````js\r\n\r\ngulp.task('wrap', function() {\r\n  gulp.src('./lib/*.js')\r\n    .pipe(wrapper({\r\n      type: 'commonjs',\r\n      deps: ['jade.runtime']\r\n    }))\r\n    .pipe(gulp.dest('./dist/'))\r\n});\r\n\r\n````\r\n\r\nThis will inject the following code ````var jade = require('jade').runtime````.\r\n\r\n## API  \r\n### wrapper(options, [ignore])  \r\n\r\n#### options.[file-name].type  \r\nType: `String`.  \r\nType of module.\r\nSupported types: `amd`, `umd`, ``commonjs``.  \r\nDefault: `amd`.  \r\n\r\n### options.[file-name].root  \r\nType: `String`.  \r\nRelative file's path.  \r\n\r\n### options.[file-name].name  \r\nType: `String`.  \r\nModule name. Useful for separate options or one-file processing.  \r\nDefault: File name.  \r\nNote: Set to ``false`` to turn off module's name optimization and leave it as it is.  \r\n\r\n### options.[file-name].prefix  \r\nType: `String`.  \r\nModule's name prefix. Will be added before module's name.  \r\nNote: Ignored if ``name`` is set to ``false``.  \r\n\r\n#### options.[file-name].deps  \r\nType: `Array`.  \r\nList of module dependencies.  \r\nNote: All modules will get default dependencies like 'exports', 'require', 'module'.  \r\n\r\n### options.[file-name].args  \r\nType: `Array`.  \r\nList of module's constructor arguments.  \r\nDefault:  All module's constructors will get default arguments like 'exports', 'require', 'module'.  \r\n\r\n### options.[file-name].exports  \r\nType: `String`.  \r\nVariable to return.  \r\nNote: Set to ``false`` to turn off module's export optimization and leave it as it is.  \r\n\r\nSeparate options can be mixed with global one, but separate options has higher priority.  \r\n\r\n### ignore  \r\nType: `Array`.  \r\nList of files or glob patterns for files that should not be processed.  \r\n\r\n## LICENSE\r\n\r\n(MIT License)\r\n\r\nCopyright (c) 2014 Tim Voronov\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining\r\na copy of this software and associated documentation files (the\r\n\"Software\"), to deal in the Software without restriction, including\r\nwithout limitation the rights to use, copy, modify, merge, publish,\r\ndistribute, sublicense, and/or sell copies of the Software, and to\r\npermit persons to whom the Software is furnished to do so, subject to\r\nthe following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be\r\nincluded in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziflex%2Fgulp-module-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziflex%2Fgulp-module-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziflex%2Fgulp-module-wrapper/lists"}