{"id":51024189,"url":"https://github.com/dsathyakumar/lasso-optimizer","last_synced_at":"2026-06-21T18:02:13.342Z","repository":{"id":42983890,"uuid":"214008839","full_name":"dsathyakumar/lasso-optimizer","owner":"dsathyakumar","description":"A Babel codemod that acts as a build / compile time optimizer for Lasso JS. Gives Lasso JS some extra arms.","archived":false,"fork":false,"pushed_at":"2023-01-06T02:11:55.000Z","size":1105,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-21T10:27:42.803Z","etag":null,"topics":["babel-codemod","lasso","lasso-js","lasso-marko","lasso-plugin","markojs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dsathyakumar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-09T19:43:30.000Z","updated_at":"2023-03-13T01:51:58.000Z","dependencies_parsed_at":"2023-02-05T02:31:19.357Z","dependency_job_id":null,"html_url":"https://github.com/dsathyakumar/lasso-optimizer","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/dsathyakumar/lasso-optimizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsathyakumar%2Flasso-optimizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsathyakumar%2Flasso-optimizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsathyakumar%2Flasso-optimizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsathyakumar%2Flasso-optimizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsathyakumar","download_url":"https://codeload.github.com/dsathyakumar/lasso-optimizer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsathyakumar%2Flasso-optimizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34620358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"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":["babel-codemod","lasso","lasso-js","lasso-marko","lasso-plugin","markojs"],"created_at":"2026-06-21T18:02:10.878Z","updated_at":"2026-06-21T18:02:13.337Z","avatar_url":"https://github.com/dsathyakumar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lasso-optimizer\n\u003eA Babel CodeMod plugin that acts as a build / compile time optimizer for Lasso JS. Gives [Lasso JS](http://www.github.com/lasso-js/lasso) some extra arms.\n\n## What is this?\n- [Lasso JS](http://www.github.com/lasso-js/lasso) produces output bundles similar to the NODEJS common-js style syntax on the browser.\n- This is an optimizer stage plugin \u0026 a Babel CodeMod for [Lasso JS](http://www.github.com/lasso-js/lasso), that is applied on the final aggregated output of [Lasso JS](http://www.github.com/lasso-js/lasso).\n- It performs code transformations\n- It cannot be used as a transform or as a usual JS plugin in the list of Lasso plugins\n\n## Why is this needed?\n- This plugin helps in further optimizing Lasso JS output bundles under certain  conditions, while resolving modules, **require.resolve**, **require**, **conditional requires** \u0026 circular dependencies.\n- Currrently, Lasso JS inlines the filepaths of modules like\n\n```javascript\n$_mod.def(\"/marko$4.17.3/components/runtime\", function (require, exports, module, __filename, __dirname) {\n    const f_55 = require('/marko$4.17.3/components/index-browser.marko');\n    exports.a = 45;\n    exports.func = () =\u003e {};\n    module.exports = () =\u003e {\n\n   };\n});\n$_mod_gh_fe.remap(\"/marko$4.17.3/components\", \"/marko$4.17.3/components-browser.marko\");\n$_mod_gh_fe.installed(\"globalheaderfrontend$25.1.0\", \"marko\", \"4.17.3\");\n$_mod_gh_fe.remap(\"/marko$4.17.3/src/runtime/components/index\", \"/marko$4.17.3/src/runtime/components/index-browser\");\n```\n- While they provide a mirror representation of your projects file system, this tends to be of an overhead \u0026 bloat for projects.\n- Further, these are resolved on the browser by [Lasso Modules Client Side Run Time](https://github.com/lasso-js/lasso-modules-client) that performs a Node JS style module resolution.\n- Inlined filepaths \u0026 the client side runtime take upto \u003e30KB-200KB in your **ungzipped** output bundle \u0026 upto 5KB-20KB in your **gzipped** response.\n- As JS parse times are impacted by bundle size bloats, this helps optimize the bundle for it.\n\n## What does this do?\n- This plugin applies an output transformation on the final aggregated code / bundle.\n- It attempts to resolve all filepaths and module dependencies at build time\n- It transform modules into simple function expressions\n\n```javascript\n$_mod.def(\"/marko$4.17.3/components/runtime\", function (require, exports, module, __filename, __dirname) {\n    // code here\n});\n$_mod.run(\"/marko$4.17.3/components/runtime\");\n$_mod_gh_fe.remap(\"/marko$4.17.3/components\", \"/marko$4.17.3/components-browser.marko\");\n$_mod_gh_fe.installed(\"globalheaderfrontend$25.1.0\", \"marko\", \"4.17.3\");\n$_mod_gh_fe.main(\"/process$4.17.3\", \"src/runtime/components/index-browser\");\n```\n\nto \n\n```javascript\nfunction __marko_4_17_3__components__runtime(require, exports, module, __filename, __dirname) {\n    /* __marko_4_17_3__components_index_browser__marko is already available in toplevel scope */\n    const f_55 = require(__marko_4_17_3__components_index_browser__marko);\n    exports.a = 45;\n    exports.func = () =\u003e {};\n    module.exports = () =\u003e {\n\n   };\n}\nrun(__marko_4_17_3__components__runtime);\n```\n- The `.remap`, `.installed`, `.main`, `.run`, `.builtin`, `resolve`, `require`, `def` are all resolved at build / asset bundling phase.\n- On the browser, the bundle doesn't have to resolve these anymore.\n- By doing this, it gets rid of the [Lasso Modules Client Side Run Time](https://github.com/lasso-js/lasso-modules-client) \u0026 uses a miniature version of it.\n\n## What do you get by doing this?\n- All inline file paths are resolved before runtime.\n- Check out the `/sample` folder for the input and output. The input is a bundle of size 404KB and copy paste the output bundle into https://try.terser.org/ with options as\n\n```javascript\n{\n  toplevel: true,\n  compress: {\n    toplevel: true\n  },\n  mangle: {\n    toplevel: true\n  },\n  output: {},\n  parse: {},\n  rename: {},\n}\n```\n**The minified output will now be 250KB.**\n\n## Usage\n- This **cannot** be applied as `transform` in the Lasso config or be used as a **plugin**.\n- This **cannot** also resolve **dynamic require calls** where the argument of require is not a **String** but an **identifier** resolved dynamically\n- The following Lasso Config is a sample where the output would be bundled for production.\n```json\n{\n    \"plugins\": [\n        \"lasso-less\",\n        \"lasso-autoprefixer\",\n        \"lasso-marko\",\n        \"lasso-minify-transpile-inline\",\n        \"rollup-plugin-lasso\",\n        {\n            \"plugin\": \"lasso-inline-slots\",\n            \"config\": {\n                \"inlineSlots\": [\n                    \"inline\"\n                ]\n            }\n        }\n    ],\n    \"require\": {\n        \"lastSlot\": \"inline\",\n        \"transforms\": [\n            \"lasso-babel-env\"\n        ]\n    },\n    \"outputDir\": \"static\",\n    \"minify\": true,\n    \"minifyInlineOnly\": true,\n    \"bundlingEnabled\": true,\n    \"resolveCssUrls\": true,\n    \"noConflict\": \"gh-fe\",\n    \"cacheProfile\": \"production\"\n}\n```\n\nNow, the above output would cause Lasso to dump the final minfied output bundled under \n`${PROJECT_DIR}/static`.\n\n```javascript\n\nconst { readFileSync, writeFileSync } = require('fs');\nconst { optimizeSingleSourceFile } = require('lasso-optimizer');\nconst code = readFileSync('static/my-awesome-bundle.js', 'utf8');\nconst result = optimizeSingleSourceFile(code);\nwriteFileSync('static/optimized-bundle.js', 'utf8');\n\n// now proceed to upload to resource server.\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsathyakumar%2Flasso-optimizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsathyakumar%2Flasso-optimizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsathyakumar%2Flasso-optimizer/lists"}