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

watcher script is not compatible with yarn workspaces #23

Closed
jakubwolny opened this issue Apr 13, 2021 · 4 comments
Closed

watcher script is not compatible with yarn workspaces #23

jakubwolny opened this issue Apr 13, 2021 · 4 comments

Comments

@jakubwolny
Copy link

jakubwolny commented Apr 13, 2021

After installing typesafe-i18n within one workspace, when you try to run the watcher:
node ./node_modules/typesafe-i18n/node/watcher.js
it does not work, since the files within node_modules are not physically located there (yarn does linking).

node ./node_modules/typesafe-i18n/node/watcher.js
internal/modules/cjs/loader.js:883
 throw err;
 ^

Error: Cannot find module '/Users/jakubwolny/projects/orca/client/node_modules/typesafe-i18n/node/watcher.js'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
   at Function.Module._load (internal/modules/cjs/loader.js:725:27)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
   at internal/main/run_main_module.js:17:47 {
 code: 'MODULE_NOT_FOUND',
 requireStack: []
}

then of course I tried to run it in the directory above (project root), but when it watches entire project, not just single workspace, and paths are all wrong. Or I haven't found a way to tell watcher to specific dir to watch i.e.
node ./node_modules/typesafe-i18n/node/watcher.js --dir=client.
Also, from a perspective of a webpack user, I find it weird that I need to start another file watcher - I already have one (in webpack). So probably it's out of the scope of that issue, but having a webpack plugin could improve a Developer Experience.

So I haven't found any easy way to make it work within yarn workspace. btw. this is the most interesting i18n project I've seen in years I wanted to give a try.

@jakubwolny
Copy link
Author

starting the watcher with:
node ../node_modules/typesafe-i18n/node/watcher.js
solved the issue - sometimes the simplest solutions are the best!
still, a webpack plugin could maybe make the adoption a bit easier

@ivanhofer
Copy link
Owner

Hi @jakubwolny,
thanks for your feedback :)

You can use the outputPath option inside the .typesafe-i18n.json-file to set the output path for the files being generated.

The reason why no webpack plugin exists yet is because I personally use rollup and haven't had the time yet to create one. The node process is currently the fallback for users who aren't using rollup ;)

@ivanhofer
Copy link
Owner

@jakubwolny as of typesafe-i18n version 2.16.0 you can also start the watcher via a webpack-plugin

@jakubwolny
Copy link
Author

oh wow! thank you for the update, I'll definitely try it

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

No branches or pull requests

2 participants