Skip to content

Conversation

@sevenc-nanashi
Copy link
Member

@sevenc-nanashi sevenc-nanashi commented Mar 1, 2025

内容

Voicevox全体をESModuleに移行します。
electron-builder周りはまだ辛そうだったのでcjsのままです。

関連 Issue

(なし)

スクリーンショット・動画など

(なし)

その他

#2581 が先。

@sevenc-nanashi sevenc-nanashi requested a review from a team as a code owner March 1, 2025 14:41
@sevenc-nanashi sevenc-nanashi requested review from Hiroshiba and removed request for a team March 1, 2025 14:41
@sevenc-nanashi sevenc-nanashi marked this pull request as draft March 1, 2025 14:45
@voicevox-preview-pages
Copy link

voicevox-preview-pages bot commented Mar 6, 2025

🚀 プレビュー用ページを作成しました 🚀

更新時点でのコミットハッシュ:7c787b3

@sevenc-nanashi sevenc-nanashi marked this pull request as ready for review March 7, 2025 05:50
Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ts書かないといけないの悲しいですね。。。

と思ったけどvoicevox_blogの方は書いてないんですよね。
ちょっと調べた感じ、moduleResolutionを設定してあげるとこういうこともなさそう・・・?
https://speakerdeck.com/uhyo/tsconfig-dot-jsonnoshe-ding-wojian-zhi-sou-hurontoendoxiang-ke-2024xia?slide=32

@sevenc-nanashi
Copy link
Member Author

.ts書かないといけないの悲しいですね。。。

正直書いてない方が気持ち悪い気持ちがあります(個人の気持ち)

@Hiroshiba
Copy link
Member

Hiroshiba commented Mar 8, 2025

結構書かない派が多そう?

vue
https://github.com/vuejs/core/blob/main/packages/runtime-core/src/components/BaseTransition.ts

vite
https://github.com/vitejs/vite/blob/main/packages/vite/src/shared/hmr.ts

実益もあって、
src/store/audio.tssrc/store/audio/index.txを等価に扱えるから便利なんですよね~

@sevenc-nanashi
Copy link
Member Author

結構書かない派が多そう

それはどちらもCommonJS(昔のNode式)を使っているからだと思います

@Hiroshiba
Copy link
Member

Hiroshiba commented Mar 8, 2025

それはどちらもCommonJS(昔のNode式)を使っているからだと思います

CommonJSだと.tsなどを書けない感じでしょうか?
書けるけど書かないなら、まあ省略派が多いということなのかなーと。

実利もあるので!(二度目)

@Hiroshiba
Copy link
Member

いろいろ調べた感じ、少なくとも今はまだ拡張子を書かないのが主流な気がしました。

tsconfigのbaseを考えてるコミュニティ的には、moduleResolutionにbundler指定したらええんちゃうって雰囲気でした。
https://github.com/tsconfig/bases#what-about-tsconfigesm

vueのtsconfig.jsonも↑だった。まあこれはesmではないですが。
https://github.com/vuejs/tsconfig/blob/main/tsconfig.json

あと半年とか1年経ってくると変わってくるかもだけど、少なくとも今じゃなさそうな直感。

@sevenc-nanashi
Copy link
Member Author

とりあえず戻しました。
拡張子を増やすときのために自分が使ったスクリプトを置いておきます:

Details
log = File.read("./__gi_log.log")

current_file = ""
file_lines = []
[*log.lines, "/dev/null"].each do |line|
  if line.start_with?("/")
    File.write(current_file, file_lines.join) unless file_lines.empty?

    current_file = line.strip
    file_lines = File.read(current_file).lines
  elsif line.include?("import/extensions")
    line, column = line.match(/ (\d+):(\d+)/).captures
    column = column.to_i - 1
    quoted = file_lines[line.to_i - 1][column..].match(/^"(.+?)"/)
    content = quoted.captures.first
    file =
      if content.start_with?("@")
        "#{__dir__}/src/#{content[2..]}.ts"
      else
        "#{File.dirname(current_file)}/#{content}.ts"
      end
    if File.exist?(file)
      file_lines[line.to_i - 1] = file_lines[line.to_i - 1].gsub(
        content,
        "#{content}.ts"
      )
    elsif File.exist?(file.gsub(/\.ts$/, "/index.ts"))
      file_lines[line.to_i - 1] = file_lines[line.to_i - 1].gsub(
        content,
        "#{content}/index.ts"
      )
    else
      warn "File not found: #{file}"
    end
  end
end

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

良い感じ!!!

electron-builder周りもいつかtsにできると嬉しいなぁ。

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

シンプル!!!

@Hiroshiba Hiroshiba enabled auto-merge March 9, 2025 21:08
@Hiroshiba Hiroshiba added this pull request to the merge queue Mar 9, 2025
Merged via the queue into VOICEVOX:main with commit b1056b1 Mar 9, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants