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

fix(@formatjs/cli): use readJSONSync instead of require #1895

Merged
merged 2 commits into from
Jul 29, 2020

Conversation

akmjenkins
Copy link
Contributor

Tested this out as per the documentation here - https://formatjs.io/docs/getting-started/message-distribution - but every time I ran the command I got

Error: Cannot find module './lang/en.json'
Require stack:
- /Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/compile.js
- /Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/cli.js
- /Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/bin/formatjs
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.compile [as default] (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/compile.js:7:20)
    at Command.<anonymous> (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/cli.js:156:41)
    at Command.listener [as _actionHandler] (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:413:31)
    at Command._parseCommand (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:914:14)
    at Command._dispatchSubcommand (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:865:18)
    at Command._parseCommand (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:882:12)
adamjenkins@MacBook-Pro web-client % npx formatjs compile ./lang/en.json --out-file compiled-lang/en.json

When I changed it to use readJSONSync (because the cli already uses fs-extra so why not) it worked like a charm. I didn't see a bug report, is anybody else experiencing this issue?

akmjenkins and others added 2 commits July 29, 2020 10:27
Tested this out as per the documentation here - https://formatjs.io/docs/getting-started/message-distribution - but every time I ran the command I got

```
Error: Cannot find module './lang/en.json'
Require stack:
- /Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/compile.js
- /Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/cli.js
- /Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/bin/formatjs
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.compile [as default] (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/compile.js:7:20)
    at Command.<anonymous> (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/src/cli.js:156:41)
    at Command.listener [as _actionHandler] (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:413:31)
    at Command._parseCommand (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:914:14)
    at Command._dispatchSubcommand (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:865:18)
    at Command._parseCommand (/Users/adamjenkins/Documents/GitHub/web-client/node_modules/@formatjs/cli/node_modules/commander/index.js:882:12)
adamjenkins@MacBook-Pro web-client % npx formatjs compile ./lang/en.json --out-file compiled-lang/en.json
```

When I changed it to use readJSONSync (because the cli already uses fs-extra so why not) it worked like a charm. I didn't see a bug report, is anybody else experiencing this issue?
@akmjenkins akmjenkins changed the title Fix compilation Fix cli compile Jul 29, 2020
@longlho
Copy link
Member

longlho commented Jul 29, 2020

Thanks a lot for your contributions!

@longlho longlho changed the title Fix cli compile fix(@formatjs/cli): use readJSONSync instead of require Jul 29, 2020
@longlho longlho merged commit 5eed1e5 into formatjs:main Jul 29, 2020
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.

None yet

3 participants