{"id":14674,"library":"lindera-wasm-ipadic-bundler","title":"Lindera WASM (IPADIC) for Bundlers","description":"This package, `lindera-wasm-ipadic-bundler`, provides a WebAssembly-based Japanese morphological analyzer specifically tailored for JavaScript bundler environments. It includes the widely used IPADIC dictionary directly embedded, enabling offline and efficient text processing. While the broader Lindera WASM ecosystem has moved to v3.x (e.g., `lindera-wasm-ipadic-web` and `lindera-wasm-ipadic-nodejs`), this particular 'bundler' target package is currently at v2.3.4. The Lindera project generally releases frequent minor updates and patches, with major versions introducing broader architectural changes, such as revised package structures. Its key differentiators include its WebAssembly foundation for performance, the convenience of bundled dictionaries, and dedicated packages optimized for different JavaScript environments (browser, Node.js, bundler).","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-ipadic-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add lindera-wasm-ipadic-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add lindera-wasm-ipadic-bundler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The `init` function is the default export and must be called to initialize the WebAssembly module. Other utilities like `TokenizerBuilder` are named exports.","wrong":"import { init, TokenizerBuilder } from 'lindera-wasm-ipadic-bundler';","symbol":"init","correct":"import init, { TokenizerBuilder } from 'lindera-wasm-ipadic-bundler';"},{"note":"`TokenizerBuilder` is a named export used to configure and create a tokenizer instance.","wrong":"import TokenizerBuilder from 'lindera-wasm-ipadic-bundler';","symbol":"TokenizerBuilder","correct":"import { TokenizerBuilder } from 'lindera-wasm-ipadic-bundler';"},{"note":"Import the `Token` type for type-safe handling of tokenized results in TypeScript projects.","symbol":"Token","correct":"import type { Token } from 'lindera-wasm-ipadic-bundler';"}],"quickstart":{"code":"import init, { TokenizerBuilder } from 'lindera-wasm-ipadic-bundler';\n\nasync function main() {\n    // Initialize the WebAssembly module. This is crucial and must be awaited\n    // before any other functions from the module can be used.\n    await init();\n\n    // Create a new TokenizerBuilder instance to configure the tokenizer.\n    const builder = new TokenizerBuilder();\n\n    // Specify the dictionary to use. 'embedded://ipadic' uses the dictionary\n    // bundled with this package.\n    builder.setDictionary(\"embedded://ipadic\");\n\n    // Set the tokenization mode, 'normal' is suitable for general text.\n    builder.setMode(\"normal\");\n\n    // Build the tokenizer with the specified settings.\n    const tokenizer = builder.build();\n\n    // Define the Japanese sentence to be tokenized.\n    const sentence = \"すもももももももものうち\";\n    const tokens = tokenizer.tokenize(sentence);\n\n    console.log(`Tokenizing sentence: \"${sentence}\"`);\n    console.log(\"--- Tokens ---\");\n\n    // Iterate over the resulting tokens and print their surface form and details.\n    tokens.forEach(token => {\n        console.log(`${token.surface} [${token.details.join(\", \")}]`);\n    });\n\n    // Demonstrate accessing specific details of a token.\n    if (tokens.length > 0) {\n        const firstToken = tokens[0];\n        console.log(`\\nFirst token surface: ${firstToken.surface}`);\n        // The details array contains information like part-of-speech, conjugation, etc.\n        console.log(`First token part of speech: ${firstToken.details[0]}`);\n    }\n}\n\n// Execute the main asynchronous function.\nmain().catch(console.error);","lang":"typescript","description":"This quickstart initializes the Lindera WASM module, configures a tokenizer with the embedded IPADIC dictionary, and demonstrates how to tokenize a Japanese sentence and access token details."},"warnings":[{"fix":"Monitor the Lindera GitHub repository and npm for the release of `lindera-wasm-ipadic-bundler` v3.x if you require the latest features or architecture. For now, be aware of the version difference when consulting documentation for other Lindera targets.","message":"The `lindera-wasm-ipadic-bundler` package is currently at v2.3.4, while other Lindera WASM packages (e.g., `-web`, `-nodejs`) have progressed to v3.x. This means features, bug fixes, and breaking changes introduced in Lindera v3 are not yet present in this specific 'bundler' package. Users expecting v3 behavior will not find it here.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Always install and import the package specifically designed for your environment. For projects using bundlers like Webpack, Rollup, or Vite, ensure you are using `lindera-wasm-ipadic-bundler`.","message":"Lindera provides separate npm packages for different JavaScript environments (e.g., `-web`, `-nodejs`, `-bundler`). Using the incorrect package for your target environment (e.g., `lindera-wasm-ipadic-nodejs` in a browser bundler context) will lead to runtime errors due to environment-specific WASM compilation targets and API differences.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Ensure that `await init()` is the very first interaction with the Lindera module in your application's entry point or wherever the module is first used. Wrap your usage in an `async` function.","message":"The WebAssembly module must be asynchronously initialized by calling `await init()` (where `init` is the default export) before any other functions from the package can be used. Forgetting to call or await this initialization function will result in runtime errors.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always use `async/await` or Promise `.then()` chains to ensure that all interactions with the Lindera WASM module occur only after it has been successfully initialized.","message":"WASM module loading and initialization are asynchronous operations. Attempting to use the `TokenizerBuilder` or other functionality synchronously before `init()` has resolved will lead to errors.","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":"For bundler environments, use `import init, { TokenizerBuilder } from 'lindera-wasm-ipadic-bundler';`. If targeting Node.js, use `lindera-wasm-ipadic-nodejs` with `const { TokenizerBuilder } = require('lindera-wasm-ipadic-nodejs');`.","cause":"Using the CommonJS `require()` syntax with a bundler-targeted package in an ECMAScript Module (ESM) context, or using a `-bundler` package in a Node.js CJS project.","error":"ReferenceError: require is not defined"},{"fix":"Ensure `init` is imported as the default export: `import init from 'lindera-wasm-ipadic-bundler';`. Also, verify your bundler is correctly handling default WASM module exports.","cause":"Incorrectly importing the default `init` function as a named export, or attempting to call it before it's properly assigned (e.g., due to an incorrect bundler configuration).","error":"TypeError: init is not a function"},{"fix":"Double-check the dictionary path. Ensure you have installed the correct package that bundles the desired dictionary, such as `lindera-wasm-ipadic-bundler` for IPADIC.","cause":"The specified dictionary path (`embedded://ipadic`) is incorrect, or a Lindera WASM package without an embedded dictionary was installed (e.g., `lindera-wasm-bundler` instead of `lindera-wasm-ipadic-bundler`).","error":"Error: The requested dictionary 'embedded://ipadic' is not found."},{"fix":"Verify your bundler (e.g., Webpack, Rollup) is configured to handle `.wasm` files. Ensure the output directory of your build includes the `.wasm` asset and that your web server is correctly serving it with the appropriate MIME type (`application/wasm`).","cause":"This usually occurs in browser/web worker environments when a bundler fails to correctly output or serve the WASM `.wasm` chunk file, or the server path for the WASM file is incorrect.","error":"TypeError: Failed to execute 'fetch' on 'WorkerGlobalScope': Failed to fetch dynamically imported module"}],"ecosystem":"npm"}