Open YoshiWalsh opened 5 years ago
I getting same issue and i fixed it ok.
"paths": { "path": [ "./node_modules/path-browserify" ] },
edit or create file typings.d.ts in the root angular project [/src/typing.d.ts] with flowing code `declare module 'kuroshiro' { export function init(options?: { dicPath?: string }, callback?: (err?: any) => void): void; export function init(callback?: (err?: any) => void): void;
export function convert(str: string, options?: { to?: 'hiragana' | 'katakana' | 'romaji', } & ConvertOptions): string;
export function toHiragana(str: string, options?: ConvertOptions): string;
export function toKatakana(str: string, options?: ConvertOptions): string;
export function toRomaji(str: string, options?: ConvertOptions): string;
export function toKana(str: string, options?: ConvertOptions): string;
export function isHiragana(str: string): boolean;
export function isKatakana(str: string): boolean;
export function isRomaji(str: string): boolean;
export function isKanji(str: string): boolean;
export function hasHiragana(str: string): boolean;
export function hasKatakana(str: string): boolean;
export function hasKanji(str: string): boolean;
interface ConvertOptions { mode?: 'normal' | 'spaced' | 'okurigana' | 'furigana', delimiter_start?: string, delimiter_end?: string }
}
declare class KuromojiAnalyzer {
constructor(dictPath?: { dictPath: string });
init(): Promise
declare module "kuroshiro-analyzer-kuromoji" { export default KuromojiAnalyzer; }`
const autokana = new (kuroshiro as any).default
await autokana.init(new KuromojiAnalyzer.default({dictPath: 'assets/dict/'}));
// Convert what you want:
const result = await autokana.convert("大澤", { to: "hiragana" });
console.log(result);
i use angular 12+
I'm using kuroshiro in my Angular project. I'm using kuroshiro-analyzer-kuromoji so that I can run it in-browser.
If I do
ng serve
it works perfectly, but if I dong build
I get the following error:Since it works with
ng serve
I'm sure there's a simple way to fix this by tweaking my webpack configuration. Unfortunately I don't know enough about webpack to work out what that change would be.I can see that other people are having this same problem, but they all seem to be facing it with React Native.
Any help would be greatly appreciated, thanks!