Skip to content
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

Custom extractor on Windows #75

Open
EtienneGuilletPackative opened this issue Mar 21, 2024 · 4 comments
Open

Custom extractor on Windows #75

EtienneGuilletPackative opened this issue Mar 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@EtienneGuilletPackative

Hello,
Whille running the following command on a Windows env tolgee sync -e './libraries/common/react-emails/scripts/extractor.ts' './libraries/common/react-emails/**/*.ts?(x)'

I get the following error

🐭🔴     Analyzing code...
🔴 An unexpected error occurred while running the command.
🔴 Please report this to our issue tracker: https://github.com/tolgee/tolgee-cli/issues
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /mnt/c/Users/etienne_packative/Dev/coreboard/libraries/common/react-emails/scripts/extractor.ts
    at new NodeError (node:internal/errors:399:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
    at defaultLoad (node:internal/modules/esm/load:81:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)

I don't have any problem with the CLI on Windows otherwise

@cyyynthia
Copy link
Collaborator

It seems TypeScript file support is in a broken stage at this time and would need some changes (and potential redesign of how it is handled)

For future reference: ts-node seems to not be able to properly hook into Node and the Node docs seem to indicate the proper hooks to bring things back is 20.6.x only, so that option is no longer viable.

The direction to take is probably to do something similar to how Vite loads its config file: simply bundle the file ourselves using typescript and write it to a temporary location so we can import it as a plain mjs file - essentially what ts-node was doing but this time it should be way more stable and future proof

@cyyynthia cyyynthia added the bug Something isn't working label Mar 25, 2024
@OrenChapo
Copy link

I'm not sure this issue is limited to TypeScript. Seems broken on Windows with a .js extractor as well.

@MathisBarre
Copy link

MathisBarre commented Apr 15, 2024

Broken on MacOS too
ts-node v10.9.2
node.js v20.6.1
tolgee-cli v1.4.0

@nikolap
Copy link

nikolap commented May 17, 2024

Also ran into issue on macos and linux. Was able to work around this mess by converting the custom extractor to commonjs (note not ES module, so module.exports = ..., etc.).

Only ran into this problem because the way to programatically delete keys is through running the sync command or writing our own script (not there yet thankfully). Quite a run around 🥴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants