## START: Set by rpmautospec ## (rpmautospec version 0.8.4) ## RPMAUTOSPEC: autorelease, autochangelog %define autorelease(e:s:pb:n) %{?-p:0.}%{lua: release_number = 1; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} ## END: Set by rpmautospec # oxc-parser ships as an unscoped npm package (install path # %%{nodejs_sitelib}/oxc-parser). The published npm package is pure JavaScript # glue (src-js/, generated by napi-rs); the actual parsing is done by a native # napi addon (@oxc-parser/binding-), which upstream distributes as # prebuilt per-platform packages. This package rebuilds that addon from source # (from the oxc-project/oxc monorepo's napi/parser crate) and ships the JS glue # from the published npm tarball, so nothing prebuilt ships. %global npm_name oxc-parser %undefine _package_note_flags Name: nodejs-oxc-parser Version: 0.127.0 Release: %autorelease Summary: Fast JavaScript/TypeScript parser implemented in Rust # oxc-parser's JS glue, the Rust napi crate and its runtime JS dependency # (@oxc-project/types) are MIT. The native addon links the vendored Rust crates, # whose licenses are enumerated in LICENSE.dependencies (generated at build time) # and in oxc-parser-%%{version}-bundled-licenses.txt (the bundled npm build # dependency, @napi-rs/cli). License: MIT URL: https://oxc.rs # Two upstream inputs: # - Source0: the oxc monorepo (GitHub tag crates_v%%{version}), the full cargo # workspace, used to build the native binding from napi/parser. The # sources script renames the extracted tree to oxc-parser-%%{version}/. # - Source1: the published npm "oxc-parser" package, providing the JS glue # (src-js/). Building that JS from source would require the full napi-rs # codegen toolchain; it is plain JavaScript (no native code), so we ship the # published artifact. Unpacks to package/. Source0: %{npm_name}-%{version}-stripped.tar.gz Source1: %{npm_name}-%{version}-npm.tgz # Runtime JS dependency of oxc-parser (@oxc-project/types). Source2: %{npm_name}-%{version}-nm-prod.tgz # Build-time JS dependency: @napi-rs/cli, which drives the napi/cargo build. Source3: %{npm_name}-%{version}-nm-dev.tgz Source4: %{npm_name}-%{version}-bundled-licenses.txt # Vendored Rust crate dependencies, so cargo can build offline (see # oxc-parser-sources.sh). Cargo.toml/Cargo.lock live at the workspace root. Source5: %{npm_name}-%{version}-vendor.tar.xz ExclusiveArch: %{nodejs_arches} Requires: nodejs24 BuildRequires: nodejs24-npm BuildRequires: /usr/bin/npm BuildRequires: nodejs24 BuildRequires: nodejs24-devel BuildRequires: cargo-rpm-macros >= 24 BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: cmake %description oxc-parser is a fast JavaScript and TypeScript parser written in Rust, part of the Oxc project. This package ships the JavaScript API together with the native napi addon (@oxc-parser/binding) built from source against the vendored Rust crate dependencies. %prep # -a3 unpacks the build-time JS modules (node_modules_dev/) and -a5 the vendored # crates (vendor/); both land at the workspace root. %setup -q -n %{npm_name}-%{version} -a3 -a5 # Unpack the published npm package (JS glue) into npmpkg/. mkdir -p npmpkg tar xzf %{SOURCE1} -C npmpkg --strip-components=1 # Unpack oxc-parser's runtime JS dependencies (-> node_modules_prod/). tar xzf %{SOURCE2} cp %{SOURCE4} . # Assemble a node_modules farm from the bundled dev modules so the napi CLI # (@napi-rs/cli) is on PATH at build time. mkdir -p node_modules pushd node_modules ln -sf ../node_modules_dev/* . mkdir -p .bin pushd .bin ln -s ../../node_modules_dev/.bin/* . popd popd # Configure cargo to build offline from the vendored crates (Source5). Cargo.toml # and Cargo.lock are at the workspace root. The monorepo's own .cargo/config.toml # only carries [alias] and [target.*] entries (no [env] table), so it does not # collide with the [env] table %%cargo_prep appends. %cargo_prep -v vendor %build # Build entirely offline. Do NOT run "npm install"; it would reach the network # and discard the bundled modules. export CARGO_NET_OFFLINE=true export npm_config_offline=true export npm_config_audit=false export npm_config_fund=false export PATH="${PWD}/node_modules/.bin:${PATH}" # Compile the native napi addon from napi/parser. This mirrors upstream's # release build script ("napi build --esm --platform ... --features allocator # --release") but drops the --js/--dts JS generation: we ship the published glue # (Source1) instead of regenerating it. Run from napi/parser so napi reads the # "napi" config from its package.json (binaryName "parser", packageName # "@oxc-parser/binding"); cargo finds the workspace and the vendored-source # config (written by %%cargo_prep at the tree root) via its upward search. With # --platform and no --target, napi builds for the host arch, emitting # parser..node. pushd napi/parser mkdir -p .napi-out napi build --platform --release --features allocator \ --manifest-path Cargo.toml \ --output-dir .napi-out popd # Record the licenses of the (vendored) Rust crate dependencies. %{cargo_license_summary} %{cargo_license} > LICENSE.dependencies %install # Ship the published JavaScript glue (src-js/) as the oxc-parser module. mkdir -p %{buildroot}%{nodejs_sitelib}/%{npm_name} cp -pr npmpkg/src-js npmpkg/package.json \ %{buildroot}%{nodejs_sitelib}/%{npm_name}/ # Bundle oxc-parser's runtime JS dependency (@oxc-project/types) under its OWN # node_modules. This keeps the package self-contained (node resolves it locally) # and makes the RPM nodejs dependency generator treat it as bundled, so it does # not emit an external npm(@oxc-project/types) require that no system package # provides. mkdir -p %{buildroot}%{nodejs_sitelib}/%{npm_name}/node_modules cp -pr node_modules_prod/* %{buildroot}%{nodejs_sitelib}/%{npm_name}/node_modules/ # Install the native addon next to the JS loader. src-js/bindings.js loads it as # ./parser..node (its local-file fallback, before any per-platform # npm package), so shipping it in src-js/ is sufficient on any arch. node_file=$(ls napi/parser/.napi-out/parser.*.node) cp -p "${node_file}" %{buildroot}%{nodejs_sitelib}/%{npm_name}/src-js/ %check # Load the *installed* ESM entry point. Importing it evaluates oxc-parser's # native binding loader, so this fails if the from-source @oxc-parser/binding # addon cannot be resolved or loaded. parseSync is a stable named export. %{__nodejs} --input-type=module -e 'import { parseSync } from "%{buildroot}%{nodejs_sitelib}/%{npm_name}/src-js/index.js"; if (typeof parseSync !== "function") { throw new Error("oxc-parser native binding did not load"); }' %files %doc npmpkg/README.md %license LICENSE %{npm_name}-%{version}-bundled-licenses.txt LICENSE.dependencies %{nodejs_sitelib}/%{npm_name} %changelog ## START: Generated by rpmautospec * Wed Aug 19 2026 Gordon Messmer - 0.127.0-1 - Package oxc-parser, building the native binding from source ## END: Generated by rpmautospec