{"name":"oxc-minify","version":"0.50.0","keywords":["minify"],"author":{"name":"Boshen and oxc contributors"},"license":"MIT","_id":"oxc-minify@0.50.0","maintainers":[{"name":"boshen","email":"boshenc@gmail.com"}],"homepage":"https://oxc.rs","bugs":{"url":"https://github.com/oxc-project/oxc/issues"},"dist":{"shasum":"597673203a3def0ec313b7de5dd58fc2d18aea5d","tarball":"http://registry-npm.ywwl.com/oxc-minify/download/oxc-minify-0.50.0.tgz","fileCount":5,"integrity":"sha512-LHrtJm22NubUzWkEXudEqPDftSgAIqHx7BdKBvQHMWCS96Wtckt0mWL/xt6E6WwsxMrr60delST7OJt5GEY0pg==","signatures":[{"sig":"MEYCIQDUE/BGgtgd+bppZmOVup1+QevDObkmTvNcsrtDkR9VhgIhANT1AIOC9OnhlkJGqzjCFCLcVIvzj1/1btJEvm1rhmbx","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/oxc-minify@0.50.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12866,"size":3226,"noattachment":false,"key":"/oxc-minify/-/oxc-minify-0.50.0.tgz"},"main":"index.js","_from":"file:oxc-minify-0.50.0.tgz","types":"./index.d.ts","funding":{"url":"https://github.com/sponsors/Boshen"},"_npmUser":{"name":"boshen","email":"boshenc@gmail.com"},"_resolved":"/tmp/e3da6d15acb2bdd82ecb888e6f5db449/oxc-minify-0.50.0.tgz","_integrity":"sha512-LHrtJm22NubUzWkEXudEqPDftSgAIqHx7BdKBvQHMWCS96Wtckt0mWL/xt6E6WwsxMrr60delST7OJt5GEY0pg==","repository":{"url":"git+https://github.com/oxc-project/oxc.git","type":"git","directory":"npm/oxc-minify"},"_npmVersion":"10.9.0","description":"Oxc minify Node API","directories":{},"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"optionalDependencies":{"@oxc-minify/binding-darwin-x64":"0.50.0","@oxc-minify/binding-darwin-arm64":"0.50.0","@oxc-minify/binding-linux-x64-gnu":"0.50.0","@oxc-minify/binding-linux-x64-musl":"0.50.0","@oxc-minify/binding-win32-x64-msvc":"0.50.0","@oxc-minify/binding-linux-arm64-gnu":"0.50.0","@oxc-minify/binding-linux-arm64-musl":"0.50.0","@oxc-minify/binding-win32-arm64-msvc":"0.50.0"},"_npmOperationalInternal":{"tmp":"tmp/oxc-minify_0.50.0_1739330739559_0.5081961957573586","host":"s3://npm-registry-packages-npm-production"},"readme":"# Oxc Minify\n\nSee [usage instructions](https://oxc.rs/docs/guide/usage/minifier).\n\nThis is alpha software and may yield incorrect results, feel free to [submit a bug report](https://github.com/oxc-project/oxc/issues/new?assignees=&labels=C-bug&projects=&template=bug_report.md).\n\n### Performance and Compression Size\n\nSee [minification-benchmarks](https://github.com/privatenumber/minification-benchmarks) for details.\n\nThe current version already outperforms `esbuild`,\nbut it still lacks a few key minification techniques\nsuch as constant inlining and dead code removal,\nwhich we plan to implement next.\n\n## Caveats\n\nTo maximize performance, `oxc-minify` assumes the input code is semantically correct.\nIt uses `oxc-parser`'s fast mode to parse the input code,\nwhich does not check for semantic errors related to symbols and scopes.\n\n## API\n\n### Functions\n\n```typescript\n// Synchronous minification\nminifySync(\n  filename: string,\n  sourceText: string,\n  options?: MinifyOptions,\n): MinifyResult\n\n// Asynchronous minification\nminify(\n  filename: string,\n  sourceText: string,\n  options?: MinifyOptions,\n): Promise<MinifyResult>\n```\n\nUse `minifySync` for synchronous minification. Use `minify` for asynchronous minification, which can be beneficial in I/O-bound or concurrent scenarios, though it adds async overhead.\n\n### Example\n\n```javascript\nimport { minifySync } from \"oxc-minify\";\n\nconst filename = \"test.js\";\nconst code = \"const x = 'a' + 'b'; console.log(x);\";\nconst options = {\n  compress: {\n    target: \"esnext\",\n  },\n  mangle: {\n    toplevel: false,\n  },\n  codegen: {\n    removeWhitespace: true,\n  },\n  sourcemap: true,\n};\nconst result = minifySync(filename, code, options);\n// Or use async version: const result = await minify(filename, code, options);\n\nconsole.log(result.code);\nconsole.log(result.map);\n```\n\n### Property-name mangling\n\nProperty mangling is opt-in and independent from identifier mangling. `include` is a JavaScript\n`RegExp` and is required when `mangleProps` is present. Its source and flags are compiled with\n[Rust's regex engine](https://docs.rs/regex/latest/regex/#syntax). Flags `i`, `m`, `s`, and `u` are\nsupported. Other JavaScript flags and unsupported syntax are reported in `errors`.\n\n```javascript\nconst result = minifySync(\"component.js\", source, {\n  mangle: false,\n  mangleProps: {\n    include: /^_/,\n    exclude: /^__public/,\n    reserved: [\"_externalApi\"],\n    quoted: false,\n    cache: previousResult?.mangleCache,\n  },\n});\n\nsaveCache(result.mangleCache);\n```\n\nThe returned `mangleCache` contains the input cache plus newly assigned names when parsing\nfinishes without errors, sorted by original name. A `false` cache value keeps that property\nunchanged. Feeding the cache back keeps recorded mappings stable for later unminified input, but\nthe cache does not discover unchanged names that exist only in another input. Callers coordinating\nseparate files must pin or reserve those names explicitly. Property mappings are\nsingle-application: do not minify already-mangled output with the same cache. Custom target names\nmay be shared deliberately, but must be valid JavaScript `IdentifierName` values and cannot be\n`__proto__`, `constructor`, or `prototype`. The original name `__proto__` is always reserved and\ncannot be used as a cache key.\n\nWith `quoted: false`, quoting is handled per occurrence: `obj._field` is eligible while\n`obj[\"_field\"]` is not. Property mangling assumes matching properties are never accessed through\narbitrary dynamic strings. Use `/* @__KEY__ */ \"_field\"` for a string that semantically names a\nproperty, such as a reflective API argument. Names reached through direct `eval`, the `Function`\nconstructor, or `with` must be reserved or excluded explicitly.\n\nProperties owned by unminified code, imported module namespaces, globals, DOM objects, or other\nhost APIs must also be excluded or reserved.\n\n## Assumptions\n\n`oxc-minify` makes some assumptions about the source code.\n\nSee https://github.com/oxc-project/oxc/blob/main/crates/oxc_minifier/README.md#assumptions for details.\n\n### Supports WASM\n\nSee https://stackblitz.com/edit/oxc-minify for usage example.\n","publish_time":1739330739735,"_cnpm_publish_time":1739330739735,"dist-tags":{"latest":"0.159.0"}}