{"id":14967514,"url":"https://github.com/pugjs/babel-plugin-transform-with","last_synced_at":"2025-08-18T13:19:09.408Z","repository":{"id":66002684,"uuid":"67270478","full_name":"pugjs/babel-plugin-transform-with","owner":"pugjs","description":"Babel plugin to convert \"with\" statements into strict mode-compatible JavaScript.","archived":false,"fork":false,"pushed_at":"2016-10-01T16:19:49.000Z","size":28,"stargazers_count":7,"open_issues_count":5,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-09T02:20:46.273Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/pugjs.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-03T04:07:39.000Z","updated_at":"2024-03-14T22:07:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e2ef42d-3e70-4409-b5fa-585f96d4df31","html_url":"https://github.com/pugjs/babel-plugin-transform-with","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"362e18c12db092a3a0039cb3d760acb9e187b0e1"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pugjs/babel-plugin-transform-with","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fbabel-plugin-transform-with","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fbabel-plugin-transform-with/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fbabel-plugin-transform-with/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fbabel-plugin-transform-with/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pugjs","download_url":"https://codeload.github.com/pugjs/babel-plugin-transform-with/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fbabel-plugin-transform-with/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269677847,"owners_count":24457888,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-09-24T13:38:10.081Z","updated_at":"2025-08-18T13:19:09.385Z","avatar_url":"https://github.com/pugjs.png","language":"JavaScript","readme":"# babel-plugin-transform-with\n\nBabel plugin that turns `with` statements into strict-mode JS.\n\n- [x] Alternative strict-mode-compatible syntax\n- [x] Falls back to global variables if a variable is not available in the object\n- [x] Supports [`this` references][this]\n- [x] Supports [nesting]\n- [x] Supports [`return`], [`break`], [`continue`]\n- [x] Supports [`yield`], [`await`]\n- [ ] Supports `arguments` (unlikely to be supported)\n\n[![Build Status](https://img.shields.io/travis/pugjs/babel-plugin-transform-with/master.svg)](https://travis-ci.org/pugjs/babel-plugin-transform-with)\n[![Dependency Status](https://img.shields.io/david/pugjs/babel-plugin-transform-with.svg)](https://david-dm.org/pugjs/babel-plugin-transform-with)\n[![NPM version](https://img.shields.io/npm/v/babel-plugin-transform-with.svg)](https://www.npmjs.org/package/babel-plugin-transform-with)\n\n[this]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/this\n[nesting]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/nested\n[`return`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/return\n[`break`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/loop-outside-single\n[`continue`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/loop-outside-multiple\n[`yield`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/generator-function\n[`await`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/async-function\n\n## Alternative syntax\n\nBabel errors out on any `with` statements during parsing by default, which can be frustrating when eventually the code will be converted anyway. This plugin implements an escape hatch using comments:\n\n```js\nwith (obj || {}) {\n  console.log(str);\n}\n\n// The `with` block above is equivalent to the following:\n\n// @with\n{\n  obj || {};\n  console.log(str);\n}\n```\n\nThis feature is enabled by default, but you could set `alternative` option to `false` to disable it.\n\n## Example output\n\n```js\nwith (obj || {}) {\n  console.log(str);\n}\n```\n\n```js\nvar _ref = obj || {};\n\n(function (console, str) {\n  console.log(str);\n})(\"console\" in _ref ?\n     _ref.console :\n     typeof console !== \"undefined\" ?\n       console :\n       undefined,\n   \"str\" in _ref ?\n     _ref.str :\n     typeof str !== \"undefined\" ?\n       a :\n       undefined);\n```\n\n## Exclude variables\n\nIf there are certain variables that should be regarded as globals and excluded from the closure, there are two ways to make this possible.\n\nThe plugin accepts an `exclude` option that takes an array of excluded variable names. This option applies to all `with`s compiled, so it is usually more suitable to be used when the variable is a global, like `Array`, `Object`, `process`, or `console`.\n\nIf you want to tweak the excluded variables on a per-instance basis, you can use `@with ignore` annotation (which works for both `with () {}` construct and the alternative syntax):\n\n```js\nvar i = 0, j = 0, k = 0;\nvar obj = { i: 1, j: 1, k: 0 };\n\n// @with exclude: i\nwith (obj) {\n  console.log(i, j);\n}\n\n// @with exclude: i, j\nwith (obj) {\n  console.log(i, j);\n}\n```\n\nresults in\n\n```js\nvar i = 0, j = 0, k = 0;\nvar obj = { i: 1, j: 1, k: 0 };\n\n(function (console, j) {\n  console.log(i, j);\n})(\"console\" in obj ? obj.console : typeof console !== \"undefined\" ? console : undefined, \"j\" in obj ? obj.j : typeof j !== \"undefined\" ? j : undefined);\n\n(function (console) {\n  console.log(i, j);\n})(\"console\" in obj ? obj.console : typeof console !== \"undefined\" ? console : undefined);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpugjs%2Fbabel-plugin-transform-with","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpugjs%2Fbabel-plugin-transform-with","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpugjs%2Fbabel-plugin-transform-with/lists"}