{"id":21512340,"url":"https://github.com/mariusschulz/gulp-iife","last_synced_at":"2025-08-15T00:33:08.408Z","repository":{"id":29112309,"uuid":"32641894","full_name":"mariusschulz/gulp-iife","owner":"mariusschulz","description":"A Gulp plugin for wrapping JavaScript code in IIFEs.","archived":false,"fork":false,"pushed_at":"2024-06-16T11:41:31.000Z","size":265,"stargazers_count":41,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-07T09:31:23.192Z","etag":null,"topics":["gulp","gulp-plugin","gulp-plugins","iife","javascript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/gulp-iife","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/mariusschulz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-21T17:19:29.000Z","updated_at":"2024-05-17T18:13:00.000Z","dependencies_parsed_at":"2022-08-25T18:30:23.892Z","dependency_job_id":"8c9124a6-9cdb-433b-8e22-5f9faa4d3f07","html_url":"https://github.com/mariusschulz/gulp-iife","commit_stats":{"total_commits":102,"total_committers":6,"mean_commits":17.0,"dds":"0.10784313725490191","last_synced_commit":"786a15e674d80ab72b9b59c11dbeb3a132990907"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusschulz%2Fgulp-iife","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusschulz%2Fgulp-iife/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusschulz%2Fgulp-iife/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusschulz%2Fgulp-iife/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariusschulz","download_url":"https://codeload.github.com/mariusschulz/gulp-iife/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229881197,"owners_count":18138643,"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":["gulp","gulp-plugin","gulp-plugins","iife","javascript"],"created_at":"2024-11-23T22:32:39.739Z","updated_at":"2024-12-15T22:14:45.863Z","avatar_url":"https://github.com/mariusschulz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-iife\n\nA Gulp plugin for wrapping JavaScript code within immediately invoked function expressions (IIFEs).\n\n\n## Install\n\n```\n$ npm install --save-dev gulp-iife\n```\n\n\n## Usage\n\n```js\nvar gulp = require(\"gulp\");\nvar iife = require(\"gulp-iife\");\n\ngulp.task(\"default\", function() {\n  return gulp.src(\"src/input.js\")\n    .pipe(iife())\n    .pipe(gulp.dest(\"dist\"));\n});\n```\n\nInput file:\n\n```js\nvar greeting = \"Hello, World!\";\nconsole.log(greeting);\n```\n\nOutput file:\n\n```js\n;(function() {\n\"use strict\";\n\nvar greeting = \"Hello, World!\";\nconsole.log(greeting);\n}());\n```\n\n\n## Options\n\nYou can configure the following options:\n\n- [`useStrict`](#usestrict)\n- [`trimCode`](#trimcode)\n- [`prependSemicolon`](#prependsemicolon)\n- [`bindThis`](#bindthis)\n- [`params`](#params)\n- [`args`](#args)\n\nHere's an example specifying all available options:\n\n```js\nvar gulp = require(\"gulp\");\nvar iife = require(\"gulp-iife\");\n\ngulp.task(\"default\", function() {\n  return gulp.src(\"src/input.js\")\n    .pipe(iife({\n      useStrict: true,\n      trimCode: true,\n      prependSemicolon: false,\n      bindThis: false,\n      params: [\"window\", \"document\", \"$\", \"undefined\"],\n      args: [\"window\", \"document\", \"jQuery\"]\n    }))\n    .pipe(gulp.dest(\"dist\"));\n});\n```\n\nInput file:\n\n```js\nvar greeting = \"Hello, World!\";\nconsole.log(greeting);\n```\n\nOutput file:\n\n```js\n(function(window, document, $, undefined) {\n\"use strict\";\n\nvar greeting = \"Hello, World!\";\nconsole.log(greeting);\n}(window, document, jQuery));\n```\n\n\n### `useStrict`\n\nA boolean indicating whether to prepend a `\"use strict\";` directive to the function body.\n\n- **Default**: `true`\n\n\n### `trimCode`\n\nA boolean indicating whether to remove leading \u0026 trailing whitespace from the code.\n\n- **Default**: `true`\n\n\n### `prependSemicolon`\n\nA boolean indicating whether to prepend a semicolon as statement terminator before the IIFE.\n\n- **Default**: `true`\n\n\n### `bindThis`\n\nA boolean indicating whether to append `.bind(this)` to the IIFE. Setting this value to `true` makes the surrounding global object available to the function, which is usually not the case in strict mode.\n\n- **Default**: `false`\n\n\n### `params`\n\nAn array of parameter names to be accepted by the IIFE. If the `args` option is not specified, the same identifiers will be passed as arguments of the function call.\n\n- **Default**: none\n\n\n### `args`\n\nAn array of argument names to be passed into the IIFE. If the `params` option is not specified, the parameters of the function will have the same names as the arguments passed.\n\n- **Default**: none\n\n\n## Source Maps\n\n*gulp-iife* supports source maps, which means you can use it like this:\n\n```js\nvar gulp = require(\"gulp\");\nvar iife = require(\"../gulp-iife/lib\");\nvar sourcemaps = require(\"gulp-sourcemaps\");\n\ngulp.task(\"default\", function() {\n  return gulp.src(\"src/input.js\")\n    .pipe(sourcemaps.init())\n    .pipe(iife({ }))\n    .pipe(sourcemaps.write(\"./\"))\n    .pipe(gulp.dest(\"./built\"));\n});\n```\n\n\n## Changelog\n\nThe changelog can be found in [CHANGELOG.md](https://github.com/mariusschulz/gulp-iife/blob/master/CHANGELOG.md).\n\n\n## Formatting\n\nIn the spirit of Gulp plugins, *gulp-iife* does one thing and one thing only: adding wrapping IIFEs.\n\nIf you'd like the resulting code to be neatly indented or otherwise formatted, pipe the output to another Gulp plugin which formats the JavaScript code, such as [gulp-esformatter](https://github.com/sindresorhus/gulp-esformatter).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariusschulz%2Fgulp-iife","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariusschulz%2Fgulp-iife","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariusschulz%2Fgulp-iife/lists"}