-
Notifications
You must be signed in to change notification settings - Fork 4
Upgrade kuromojin #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PR.
I've commented
src/no-dropping-i.js
Outdated
import { RuleHelper } from "textlint-rule-helper"; | ||
import kuromojin from "kuromojin"; | ||
const { RuleHelper } = require("textlint-rule-helper"); | ||
const kuromojin = require("kuromojin"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use require
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I use import kuromojin from "kuromojin";
, the following error occured in yarn test
.
1) no-dropping-i
見てます。:
TypeError: Cannot read property 'tokenize' of undefined
at /home/hata/textlint-rule-no-dropping-i/src/no-dropping-i.js:23:30
at /home/hata/textlint-rule-no-dropping-i/node_modules/@textlint/kernel/src/task/promise-event-emitter.ts:27:35
at Array.forEach (<anonymous>)
at RuleTypeEmitter.PromiseEventEmitter.emit (node_modules/@textlint/kernel/src/task/promise-event-emitter.ts:26:38)
at Controller.enter (node_modules/@textlint/kernel/src/task/textlint-core-task.ts:157:53)
at Controller.__execute (node_modules/@textlint/ast-traverse/src/index.ts:51:31)
at Controller.traverse (node_modules/@textlint/ast-traverse/src/index.ts:132:28)
at TextLintCoreTask.startTraverser (node_modules/@textlint/kernel/src/task/textlint-core-task.ts:152:28)
at TextLintCoreTask.start (node_modules/@textlint/kernel/src/task/linter-task.ts:43:14)
at /home/hata/textlint-rule-no-dropping-i/node_modules/@textlint/kernel/src/task/task-runner.ts:28:18
at new Promise (<anonymous>)
at Function.TaskRunner.process (node_modules/@textlint/kernel/src/task/task-runner.ts:16:16)
at LinterProcessor.process (node_modules/@textlint/kernel/src/linter/linter-processor.ts:55:27)
at TextlintKernel._parallelProcess (node_modules/@textlint/kernel/src/textlint-kernel.ts:155:14)
at /home/hata/textlint-rule-no-dropping-i/node_modules/@textlint/kernel/src/textlint-kernel.ts:83:25
And, it seems src/no-dropping-i.js
uses CommonJS module.exports
.
module.exports = function(context) {
So, I rewrote to CommonJS require()
.
Alternative solution: import * as
import * as kuromojin from "kuromojin";
いつも Twitter 経由で JSer.info を見させてもらっています。
本年はありがとうございました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokenize
is named exports.
We should use named import to import tokenize
.
import { tokenize } from "kuromoji"
I like es imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 We will change exports
to export default
, but it requires major updates.
(also rewrite it by TypeScript?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to use ESModules import
.
No description provided.