# What changed in highlight-words-core

> 22 changes in highlight-words-core 2 from its official release notes, upgrade guides and advisories: 10 breaking, 4 new APIs and options. Each one cited. Sources checked 2026-10-19. HTML: https://unstale.sh/npm/highlight-words-core/

To see which of these apply to a repository, run `npx @unstale/cli init` in it.

## highlight-words-core 2

### Breaking changes

- String search words are matched literally by default. Use RegExp search words to match patterns, or set autoEscape to false for trusted input. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Chunk is a union of highlighted and non-highlighted chunks; check chunk.highlight before reading searchIndex, and use literal highlight values when constructing chunks. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- combineChunks no longer sorts its input array in place and always returns new chunk objects. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Published code uses modern JavaScript syntax instead of ES5 output; older environments and bundlers that cannot parse it need to transpile the package. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- findChunks and combineChunks no longer include a highlight property in returned chunks; final chunks from findAll and fillInChunks still do. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Custom findChunks functions must include searchIndex in each returned chunk, identifying the matching word's index within searchWords. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Custom findChunks functions receive searchWords as a ReadonlyArray; mutable-array parameter declarations must be updated. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- The package ships CommonJS and ES module builds and defines exports, so only the package root can be imported; deep imports and previously published src/*.js files are unavailable. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Non-string search words from untyped callers are matched as strings instead of being skipped when falsy. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- The package is written in TypeScript and ships TypeScript declarations; Flow types are no longer included. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)

### New APIs and options

- HighlightedChunk is an exported type for highlighted chunks. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- NonHighlightedChunk is an exported type for non-highlighted chunks. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Highlighted chunks include searchIndex, the index within searchWords of the matching search word. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- searchWords can include RegExp objects, which are used as-is with their own flags. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)

### Behavior and default changes

- With autoEscape false, invalid regular-expression string search words are matched literally instead of throwing an error. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- When sanitize changes text, it is applied character by character so matches can map back to the original text; context-dependent sanitizers can produce different results. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)

### Fixes and other changes

- Custom findChunks results extending outside the text or ending before they start no longer produce invalid or overlapping chunks. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Matches map back to the original text when sanitize changes its length. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- searchWords can be a readonly array, such as an array declared with as const. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Missing searchWords values no longer throw an error; nothing is highlighted. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Surrogate pairs, such as emoji, are no longer split between chunks. (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
- Missing textToHighlight values are no longer searched as strings such as "undefined". (2.0.0) — [release notes](https://github.com/bvaughn/highlight-words-core/releases/tag/2.0.0)
