{"id":13727469,"url":"https://github.com/kwonoj/libsass-asm","last_synced_at":"2025-09-27T14:31:54.493Z","repository":{"id":66079758,"uuid":"140193874","full_name":"kwonoj/libsass-asm","owner":"kwonoj","description":"WebAssembly based Javascript bindings for libsass","archived":true,"fork":false,"pushed_at":"2018-11-05T01:27:13.000Z","size":357,"stargazers_count":47,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-25T19:08:54.366Z","etag":null,"topics":["libsass","sass","sassc","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/kwonoj.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":"2018-07-08T18:50:05.000Z","updated_at":"2024-01-25T20:31:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"84a56daf-60ee-44ce-a80a-2a60c141d34e","html_url":"https://github.com/kwonoj/libsass-asm","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Flibsass-asm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Flibsass-asm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Flibsass-asm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Flibsass-asm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kwonoj","download_url":"https://codeload.github.com/kwonoj/libsass-asm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234444021,"owners_count":18833643,"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":["libsass","sass","sassc","wasm","webassembly"],"created_at":"2024-08-03T01:03:58.385Z","updated_at":"2025-09-27T14:31:49.178Z","avatar_url":"https://github.com/kwonoj.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/kwonoj/libsass-asm/tree/master.svg?style=svg)](https://circleci.com/gh/kwonoj/libsass-asm/tree/master)\n[![npm](https://badgen.now.sh/npm/v/libsass-asm)](https://badgen.now.sh/npm/v/libsass-asm)\n[![node](https://badgen.now.sh/badge/node/%3E%3D8.0)](https://www.npmjs.com/package/libsass-asm)\n\n# libsass-asm\n\n`libsass-asm` is javascript binding to [libsass](https://github.com/sass/libsass) based on WebAssembly libsass binary. This module aims to provide transparent binding to libsass without requiring native modules, to serve as building blocks for tools.\n\n- Node.js only\n: `libsass-asm` intended to be used for node.js based toolchains.\n- Native WebAssembly binary\n: Does not provide fallbacks for old version support, works only on node.js supports native web assembly.\n- Transparent binding to libsass interface : Provides 1:1 corresponding interfaces to libsass, furthermore exposes raw interface to libsass itself.\n\n# Install\n\n```sh\nnpm install libsass-asm\n```\n\n# Usage\n\n## Using libsass interface\n`libsass-asm` relies on wasm binary of libsass, which need to be initialized first.\n\n```ts\nimport { loadModule } from 'libsass-asm';\n\nconst sassFactory: SassFactory = await loadModule();\n```\n\n`loadModule` loads wasm binary, initialize it, and returns [factory object](https://github.com/kwonoj/libsass-asm/blob/master/src/SassFactory.ts) to create instance of sass interface class. Factory object provide static creation method for each sass* interfaces, for example you can create class to handle sass_options* interface via\n\n```ts\nconst sassOptions: SassOptionsInterface = sassFactory.options.create();\n```\n\nthen via `sassOptions` object can invoke sass_options* interface.\n\n*Snippet of `SassOptionsInterface`*\n```ts\ninterface SassOptionsInterface {\n  ...\n  /**\n   * Property accessor to `sass_option_(get|set)_precision`\n   */\n  precision: number;\n\n  /**\n   * Property accessor to `sass_option_(get|set)_output_style`\n   */\n  outputStyle: OutputStyle;\n\n  /**\n   * Property accessor to `sass_option_(get|set)_source_comments`\n   */\n  sourceComments: boolean;\n\n  /**\n   * Property accessor to `sass_option_(get|set)_is_indented_syntax_src`\n   */\n  isIndentedSyntaxSrc: boolean;\n\n  /**\n   * Property accessor to `sass_option_(get|set)_omit_source_map_url`\n   */\n  omitMapComment: boolean;\n  ...\n}\n```\n\n## Mounting files\nWebAssembly binary's memory space is separately allocated and cannot use node.js's filesystem access directly. To support it `libsass-asm` exposes few interfaces interop physical file via `SassFactory::interop` object.\n\n- `mount(dirPath: string): string` : mount physical path. Once directory is mounted libsass can read all files under mounted path. Returns `virtual` path to mounted path.\n- `unmount(mountedFilePath: string): void` : Unmount path if it's mounted.\n\nAll of `virtual` paths for mounted filesystem uses unix separator regardless of platform.\n\nNote when setting options for libsass, it should be mounted path instead of physical path since libsass will try to read via mounted path only.\n\n```ts\nconst inputFile = path.resolve('./input.scss');\nconst mountedPath = sassFactory.interop.mount('./');\n\nconst sassOptions: SassOptionsInterface = sassFactory.options.create();\n\nsassOptions.inputPath = inputFile; //this will fail!\nsassOptions.inputPath = unixify(path.join(mountedPath, 'input.scss'));\n```\n\nIf input file have import paths, those paths should be mounted as well.\n\n## Using libsass interface without class factory (advanced)\nMost of sass_* bindings in `SassFactory` are written in ES classes. If you prefer to directly deal with C api style of libsass instead you can use `SassFactory::raw` object. `libsass-asm` internally contains wrapped function to call libsass functions in javascript, raw object exposes it directly.\n\n```ts\nconst { raw } = await loadModule();\n\n//calling `struct Sass_Options* sass_make_options (void);`\nconst sassOptionPtr: number = raw.context.make_options();\n```\n\nAs written in above snippet, those interface does not marshall any values but return pointers directly so it have to be dealt with.\n\n## Using cli\nIn addition to interface to libsass, `libsass-asm` provides cli as well. This is primarily to be used to run [test suite for libsass](https://github.com/sass/sass-spec) but can be used fo other usage as well.\n\n```sh\n$ sass -h\n\nOptions\n\n  -s, --stdin               Read input from standard input instead of an input file.\n  -t, --style               Output style. Can be: nested, expanded, compact, compressed.\n  -l, --line-numbers        Emit comments showing original line numbers.\n  -I, --load-path           Set Sass import path.\n  -P, --plugin-path         Set path to autoload plugins.\n  -m, --sourcemap           Emit source map (auto or inline).\n  -M, --omit-map-comment    Omits the source map url comment.\n  -p, --precision number    Set the precision for numbers.\n  -a, --sass                Treat input as indented syntax.\n  -v, --version             Display compiled versions.\n  -h, --help                Display this help message.\n  --files string[]          Specifies files for in order of [INPUT] [OUTPUT]\n                            Do not need to explicitly specify --files args\n  --root string[]           Top level path where sass inputs are located if there are import paths exist\n                            other than input path.\n\nEnabling verbose debug log\n\n  Set 'DEBUG' environment variable to any to enable debug log\n  $ DEBUG=* sass ...\n```\n\nCommand line args interface mostly mirrors [sassc](https://github.com/sass/sassc), one notable difference is providing `root` options to specify which path to mount other than input file's path.\n\n# Building / Testing\n\nFew npm scripts are supported for build / test code.\n\n- `build`: Transpiles code to ES5 commonjs to `dist`.\n- `lint`: Run lint over all codebases\n- `lint:staged`: Run lint only for staged changes. This'll be executed automatically with precommit hook.\n- `commit`: Commit wizard to write commit message\n\n# License\n\n- libsass: [original license](https://github.com/sass/libsass/blob/master/LICENSE)\n- libsass-asm: [MIT](https://github.com/kwonoj/libsass-asm/blob/master/LICENSE)\n\n*NOTE: libsass-asm is **NOT** affiliated with official libsass and sass project.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwonoj%2Flibsass-asm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkwonoj%2Flibsass-asm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwonoj%2Flibsass-asm/lists"}