lokalise / i18n-ally

🌍 All in one i18n extension for VS Code
https://marketplace.visualstudio.com/items?itemName=lokalise.i18n-ally
MIT License
4k stars 321 forks source link

在package.json中添加type: "module"后插件找不到文案文件 #963

Open maddenBoy opened 1 year ago

maddenBoy commented 1 year ago

Describe the bug 在项目中的package.json文件中加上"type": "module"属性后,插件无法识别翻译文件路径

Extension Version v2.9.1

Framework/i18n package you are using vue-i18n

To Reproduce Steps to reproduce the behavior: 1.在项目中的package.json文件中加上"type": "module"

  1. 设置"i18n-ally.localesPaths"文件目录
  2. 翻译进度,翻译树等均无数据

Device Infomation -OS: Windows

Extension Log Go to View -> Output -> i18n Ally, and paste the content below. You should mask any sensitive information

Directory structure: dir
🗃 Path Matcher Regex: /^(?<locale>[\w-_]+)(?:.*\/|^).*\.(?<ext>json|m?js)$/

📂 Loading locales under e:\RDProject\work5.0\wflow-web-pro-vue3\src\i18n
    📑 Loading (en) en_US/index.js [1688449267306.03]
        🐛 Failed to load Error: Command failed: node "c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\bin.js" --dir "e:\RDProject\work5.0\wflow-web-pro-vue3" --transpile-only --compiler-options "{\"importHelpers\":false,\"allowJs\":true,\"module\":\"commonjs\"}" "c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js" "e:\RDProject\work5.0\wflow-web-pro-vue3\src\i18n\en_US\index.js"

c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:710
        return old(m, filename);
               ^
Error [ERR_REQUIRE_ESM]: require() of ES Module e:\RDProject\work5.0\wflow-web-pro-vue3\src\i18n\en_US\index.js from c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js not supported.
Instead change the require of index.js in c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js to a dynamic import() which is available in all CommonJS modules.
    at require.extensions.<computed> [as .js] (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:710:16)
    at c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:46:21
    at step (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:32:23)
    at Object.next (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:13:53)
    at c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:3:12)
    at c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:38:23
    at Object.<anonymous> (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:58:7)
    at m._compile (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:708:29)
    at require.extensions.<computed> [as .js] (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:710:16)
    at main (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\bin.js:154:20)
    at Object.<anonymous> (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\bin.js:238:5)

    📑 Loading (zh) zh_CN/index.js [1688449270669.5889]
        🐛 Failed to load Error: Command failed: node "c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\bin.js" --dir "e:\RDProject\work5.0\wflow-web-pro-vue3" --transpile-only --compiler-options "{\"importHelpers\":false,\"allowJs\":true,\"module\":\"commonjs\"}" "c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js" "e:\RDProject\work5.0\wflow-web-pro-vue3\src\i18n\zh_CN\index.js"

c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:710
        return old(m, filename);
               ^
Error [ERR_REQUIRE_ESM]: require() of ES Module e:\RDProject\work5.0\wflow-web-pro-vue3\src\i18n\zh_CN\index.js from c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js not supported.
Instead change the require of index.js in c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js to a dynamic import() which is available in all CommonJS modules.
    at require.extensions.<computed> [as .js] (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:710:16)
    at c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:46:21
    at step (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:32:23)
    at Object.next (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:13:53)
    at c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:3:12)
    at c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:38:23
    at Object.<anonymous> (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\assets\loader.js:58:7)
    at m._compile (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:708:29)
    at require.extensions.<computed> [as .js] (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\index.js:710:16)
    at main (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\bin.js:154:20)
    at Object.<anonymous> (c:\Users\87386\.vscode\extensions\lokalise.i18n-ally-2.9.1\node_modules\ts-node\dist\bin.js:238:5)

👀 Watching change on e:\RDProject\work5.0\wflow-web-pro-vue3\src\i18n
✅ Loading finished

Screenshots

johnson0903 commented 1 year ago

same issue

ZZholiday commented 5 months ago

what the same fucking issue