{"id":11401,"library":"nlcst-emoticon-modifier","title":"nlcst-emoticon-modifier","description":"nlcst-emoticon-modifier is a specialized utility within the `unified` ecosystem, designed to process Natural Language Concrete Syntax Trees (NLCST). It identifies ASCII-based emoticons (e.g., `:)`, `:(`) within text and transforms them into dedicated `EmoticonNode` objects in the syntax tree. This package is currently stable at version `3.0.1` and follows the `unified` collective's release strategy, which typically involves new major versions for significant breaking changes like Node.js version updates or module system transitions. It is a foundational tool for natural language processing, offering a precise way to classify emoticons, distinguishing itself by its integration with the `nlcst` specification and its ESM-only distribution. Higher-level plugins, such as `retext-emoji`, build upon this utility for broader emoji and emoticon support.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/nlcst-emoticon-modifier","tags":["javascript","unist","nlcst","nlcst-util","util","utility","emoticon","emoticons","typescript"],"install":[{"cmd":"npm install nlcst-emoticon-modifier","lang":"bash","label":"npm"},{"cmd":"yarn add nlcst-emoticon-modifier","lang":"bash","label":"yarn"},{"cmd":"pnpm add nlcst-emoticon-modifier","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is ESM-only since v2.0.0 and requires Node.js 16+ since v3.0.0. There is no default export.","wrong":"const emoticonModifier = require('nlcst-emoticon-modifier')","symbol":"emoticonModifier","correct":"import { emoticonModifier } from 'nlcst-emoticon-modifier'"},{"note":"Used for TypeScript type annotations. Importing the utility also registers the Emoticon node type with `@types/nlcst` globally.","wrong":"import { Emoticon } from 'nlcst-emoticon-modifier'","symbol":"Emoticon","correct":"import type { Emoticon } from 'nlcst-emoticon-modifier'"}],"quickstart":{"code":"import { emoticonModifier } from 'nlcst-emoticon-modifier';\nimport { ParseEnglish } from 'parse-english';\nimport { inspect } from 'unist-util-inspect';\n\nconst parser = new ParseEnglish();\nparser.tokenizeSentencePlugins.unshift(emoticonModifier);\n\nconst sentence = parser.parse('This makes me feel :).').children[0].children[0];\n\nconsole.log(inspect(sentence));","lang":"typescript","description":"Demonstrates how to integrate `emoticonModifier` into a `ParseEnglish` pipeline to transform ASCII emoticons into `EmoticonNode`s within an NLCST sentence, then inspects the resulting tree."},"warnings":[{"fix":"Ensure your Node.js environment is version 16 or newer. Update by using `nvm install 16` or similar version management tools.","message":"Version 3.0.0 updated the minimum Node.js requirement to Node.js 16 and above.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Migrate your project to use ES modules (`import`/`export` syntax). If you must use CommonJS, you will need to stick to `nlcst-emoticon-modifier@^1`.","message":"Version 2.0.0 switched the package to be ESM-only. CommonJS `require()` statements are no longer supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always use the main entry point `import { symbol } from 'nlcst-emoticon-modifier'`. Avoid direct deep imports into internal files unless explicitly documented, as these are no longer stable.","message":"Version 3.0.0 introduced the `exports` field in `package.json`, which affects how modules are resolved, especially for direct file imports (e.g., `require('pkg/file.js')`).","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Consumers should now rely on the main module's type declarations which provide the `Emoticon` type.","message":"Version 3.0.0 removed the `complex-types.d.ts` file.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Add `import type { Emoticon } from 'nlcst-emoticon-modifier';` or `/** @typedef {import('nlcst-emoticon-modifier')} */` to a relevant TypeScript file in your project.","message":"To correctly register the `Emoticon` node type for TypeScript within the `nlcst` ecosystem (e.g., for `unist-util-visit`), you need to import the `nlcst-emoticon-modifier` package somewhere in your type declarations or application.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Refactor your code to use `import { emoticonModifier } from 'nlcst-emoticon-modifier'` within an ES module context. Ensure your `package.json` has `\"type\": \"module\"` or files end with `.mjs`.","cause":"Attempting to use `require()` to import an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/nlcst-emoticon-modifier/index.js not supported."},{"fix":"Use a named import: `import { emoticonModifier } from 'nlcst-emoticon-modifier'`. The package does not provide a default export.","cause":"Incorrectly importing the `emoticonModifier` symbol, typically by trying to import a default export or using `require()` incorrectly.","error":"TypeError: emoticonModifier is not a function"},{"fix":"Ensure `npm install` has been run and `@types/nlcst` is installed if you're working with nlcst nodes directly. Check `tsconfig.json` for `moduleResolution` set to `node16` or `bundler` for modern ESM environments.","cause":"TypeScript compiler cannot locate the type definitions for the package, often related to `moduleResolution` settings or `skipLibCheck`.","error":"TS2307: Cannot find module 'nlcst-emoticon-modifier' or its corresponding type declarations."}],"ecosystem":"npm"}