Skip to content

refactor: modernize to ES6+ (Node 10) with perf improvements#86

Merged
alexander-akait merged 3 commits intomainfrom
claude/modernize-styles-es6-sCs9o
Apr 23, 2026
Merged

refactor: modernize to ES6+ (Node 10) with perf improvements#86
alexander-akait merged 3 commits intomainfrom
claude/modernize-styles-es6-sCs9o

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

@alexander-akait alexander-akait commented Apr 23, 2026

refactor: rewrite code to more modern

claude added 2 commits April 16, 2026 18:54
Bump engines.node to >=10.13.0 and modernize the loader runner:

- Replace `arguments`/`Array.prototype.slice.call` and `.apply(null, arguments)`
  with rest parameters and spread calls across `runSyncOrAsync`,
  `iterateNormalLoaders`, `iteratePitchingLoaders`, and `processResource`.
- Convert the normal/pitching iteration from recursion to iterative while
  loops so chains of already-executed or pitch-less loaders no longer grow
  the call stack and no longer allocate closures per skipped loader.
- Add `escapeHash`, a short-circuiting `#`-escape helper, so the `request`
  and `resource` getters skip the regex scan when the input contains no `#`.
- Replace `.slice().map().concat().join("!")` request composition with a
  single `joinRequests` loop (and a dedicated small loop for
  `previousRequest`), avoiding the intermediate arrays.
- Destructure the object-form `request` assignment, collapse the
  `null`/`undefined` options branch, and clean up the getters with arrow
  helpers and `.slice()` for dependency getters.
- In `loadLoader.js`, drop the legacy `process.nextTick` EMFILE fallback
  and use `setImmediate(loadLoader, loader, callback)` directly, and
  remove the obsolete eslint-disable for `pathToFileURL`.
- Drop the `Error.captureStackTrace` shim in `LoaderLoadingError` since
  Node 10+ captures stack traces correctly for subclassed Errors.
- `utf8BufferToString` detects the UTF-8 BOM (EF BB BF) on the Buffer
  directly and passes an offset to `toString("utf8", 3)`, avoiding the
  need to decode then `slice(1)` a JS string for BOM-prefixed inputs.
- Replace `args.some(predicate)` in the pitch callback with a tight
  for-loop so we don't allocate an arrow closure per pitched loader.
- Use a direct `args[0]` read in `processResource` instead of array
  destructuring when assigning `resourceBuffer`.
- Drop the now-dead `Object.preventExtensions` guards (always present
  on Node 10+).
- Drop the `|| ""` coalesces and the redundant `remainingRequest`
  short-circuit: `loaderContext.resource` is always a string, and
  `joinRequests` naturally returns `""` when start >= end with an
  empty resource, so the extra branches only added overhead.
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 23, 2026

CLA Not Signed

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 96.49123% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.31%. Comparing base (9fa0836) to head (3da9861).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/LoaderRunner.js 97.11% 3 Missing ⚠️
lib/loadLoader.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #86      +/-   ##
==========================================
+ Coverage   92.74%   94.31%   +1.57%     
==========================================
  Files           3        3              
  Lines         262      264       +2     
==========================================
+ Hits          243      249       +6     
+ Misses         19       15       -4     
Flag Coverage Δ
integration 94.31% <96.49%> (+1.57%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexander-akait alexander-akait merged commit 2776643 into main Apr 23, 2026
31 of 32 checks passed
@alexander-akait alexander-akait deleted the claude/modernize-styles-es6-sCs9o branch April 23, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants