{"id":13468,"library":"lindera-wasm-ko-dic-bundler","title":"Lindera WASM Korean Dictionary for Bundlers","description":"The `lindera-wasm-ko-dic-bundler` package provides the Lindera morphological analysis library compiled to WebAssembly, specifically bundled with the Korean dictionary (ko-dic) and optimized for use within modern JavaScript bundler environments (e.g., webpack, Rollup, Vite). Lindera is a high-performance, multi-dictionary capable morphological analyzer originally written in Rust. The current stable version for the v3 series is `3.0.5` across the Lindera WASM ecosystem, with `2.3.4` being the last significant release in the v2 series for this specific bundler package. The project exhibits an active release cadence, frequently publishing patch and minor updates. Its primary differentiators include its WebAssembly compilation for efficient client-side or server-side (via bundler) execution, the convenience of pre-packaged dictionaries for various languages like Korean, and the inherent performance advantages offered by a Rust-native implementation. It maintains a well-structured package ecosystem with distinct targets for web browsers, Node.js, and bundlers, each offering different pre-loaded dictionary configurations.","status":"active","version":"2.3.4","language":"javascript","source_language":"en","source_url":"https://github.com/lindera/lindera","tags":["javascript","morphological","analysis","library","wasm","webassembly","typescript"],"install":[{"cmd":"npm install lindera-wasm-ko-dic-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add lindera-wasm-ko-dic-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add lindera-wasm-ko-dic-bundler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is typically a default export function required to initialize the WebAssembly module before any other module exports can be used.","wrong":"import { __wbg_init } from 'lindera-wasm-ko-dic-bundler';","symbol":"__wbg_init","correct":"import __wbg_init from 'lindera-wasm-ko-dic-bundler';"},{"note":"Since v3, Lindera WASM packages are primarily ESM-first. CommonJS `require` should be avoided in modern bundler setups.","wrong":"const { TokenizerBuilder } = require('lindera-wasm-ko-dic-bundler');","symbol":"TokenizerBuilder","correct":"import { TokenizerBuilder } from 'lindera-wasm-ko-dic-bundler';"},{"note":"Import the `Token` type for TypeScript applications to correctly type the tokenizer's output, which is an array of `Token` objects.","symbol":"Token","correct":"import type { Token } from 'lindera-wasm-ko-dic-bundler';"}],"quickstart":{"code":"import __wbg_init, { TokenizerBuilder } from 'lindera-wasm-ko-dic-bundler';\n\nasync function main() {\n    // Initialize the WebAssembly module\n    await __wbg_init();\n\n    // Create a new tokenizer builder\n    const builder = new TokenizerBuilder();\n\n    // Set the dictionary to the embedded Korean dictionary\n    builder.setDictionary(\"embedded://ko-dic\");\n\n    // Set the tokenization mode (e.g., \"normal\", \"decompose\", \"concatenate\")\n    builder.setMode(\"normal\");\n\n    // Build the tokenizer\n    const tokenizer = builder.build();\n\n    // Text to tokenize\n    const text = \"안녕하세요 한국어 형태소 분석입니다. Lindera는 빠르고 정확합니다.\";\n\n    // Tokenize the text\n    const tokens = tokenizer.tokenize(text);\n\n    console.log(`Original text: \"${text}\"`);\n    console.log(\"\\nTokenized results:\");\n    tokens.forEach(token => {\n        console.log(`- Surface: '${token.surface}', Details: [${token.details.join(\", \")}]`);\n    });\n}\n\nmain();","lang":"typescript","description":"Initializes the WebAssembly module and demonstrates basic Korean morphological analysis using the embedded `ko-dic` dictionary with a bundler-compatible import."},"warnings":[{"fix":"Review the new package names and target environments (e.g., `lindera-wasm-ko-dic-web` for browsers, `lindera-wasm-ko-dic-nodejs` for Node.js, `lindera-wasm-ko-dic-bundler` for bundlers) and update your `package.json` and import paths accordingly. For Node.js-only applications not requiring bundling, consider the `lindera-nodejs` crate for potentially better performance via NAPI-RS bindings.","message":"Version 3.0.0 introduced significant breaking changes across the Lindera WASM ecosystem, including renaming npm packages (e.g., `-web` for browser, `-nodejs` for Node.js, `-bundler` for bundlers) and restructuring target environments. This package (`lindera-wasm-ko-dic-bundler`) is part of the new naming convention.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure your project uses `import` statements for `lindera-wasm-ko-dic-bundler`. If you are in a CommonJS environment that needs to consume ESM, you might need dynamic `import()` or specific bundler configurations (e.g., setting `\"type\": \"module\"` in your `package.json`).","message":"The `lindera-wasm` ecosystem generally moved towards ESM-first imports since v3, especially for bundler and web targets. Direct CommonJS `require()` might not work or could lead to compatibility issues in certain bundler configurations without proper transpilation.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always `await __wbg_init();` at the very start of your application or before the first usage of `TokenizerBuilder` or other Lindera WASM module exports. Wrap your initialization and usage logic in an `async` function.","message":"The `__wbg_init()` function must be called and awaited exactly once before any other functions (like `TokenizerBuilder`) from the WASM module can be used. Failing to do so will result in runtime errors as the WASM module will not be properly loaded and instantiated.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Select the appropriate `lindera-wasm-*` package that specifically bundles the dictionary for the language you intend to analyze. For Korean text analysis, ensure you are using a package like `lindera-wasm-ko-dic-bundler` and call `builder.setDictionary(\"embedded://ko-dic\");`.","message":"Each `lindera-wasm-*` package comes with a specific pre-embedded dictionary. Using the wrong package for your target language (e.g., using `lindera-wasm-ipadic-bundler` for Korean text) will result in incorrect or suboptimal morphological analysis due to a mismatch between the dictionary and the input language.","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":"Ensure you `await __wbg_init();` once at the beginning of your application before attempting to use any other exports like `TokenizerBuilder`. Verify the import path `lindera-wasm-ko-dic-bundler` is correctly specified.","cause":"This error typically occurs because the WebAssembly module has not been initialized by calling `__wbg_init()`, or the import path for the module is incorrect.","error":"TypeError: Cannot read properties of undefined (reading 'TokenizerBuilder')"},{"fix":"For the `lindera-wasm-ko-dic-bundler` package, the correct identifier is `\"embedded://ko-dic\"`. Double-check the README or package documentation for the exact dictionary string if using a different Lindera WASM package.","cause":"The `setDictionary()` method was called with an incorrect dictionary identifier string, or a dictionary that is not actually embedded within the specific `lindera-wasm-*` package you are using.","error":"Error: dictionary loading error: Dictionary file not found."},{"fix":"Ensure you are using `import { TokenizerBuilder } from 'lindera-wasm-ko-dic-bundler';` syntax. If in a Node.js project, ensure your `package.json` includes `\"type\": \"module\"` for ESM compatibility, or use dynamic `import()` for CJS environments.","cause":"You are attempting to use CommonJS `require()` syntax or your bundler is configured to treat the `lindera-wasm-ko-dic-bundler` package as CommonJS, but it is an ESM-first module.","error":"SyntaxError: Named export 'TokenizerBuilder' not found. The requested module 'lindera-wasm-ko-dic-bundler' does not provide an export named 'TokenizerBuilder'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}