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

Vite: Could not resolve "ts-node" #1464

Closed
timofei-iatsenko opened this issue Feb 24, 2023 · 2 comments · Fixed by #1466
Closed

Vite: Could not resolve "ts-node" #1464

timofei-iatsenko opened this issue Feb 24, 2023 · 2 comments · Fixed by #1466
Assignees

Comments

@timofei-iatsenko
Copy link
Collaborator

Vite project on StackBlitz.

This will show when run

 [ERROR] Could not resolve "ts-node"

    node_modules/cosmiconfig-typescript-loader/dist/cjs/index.js:28:29:
      28 │ var import_ts_node = require("ts-node");
         ╵                              ~~~~~~~~~

  You can mark the path "ts-node" as external to exclude it from the bundle, which will remove this
  error. You can also surround this "require" call with a try/catch block to handle this failure at
  run-time instead of bundle-time.

That's unexpected behaviour.

@timofei-iatsenko

This comment was marked as outdated.

@timofei-iatsenko
Copy link
Collaborator Author

Well, i've found a root cause. It's not related to config loading, it's related to macro import in the code itself. Vite before serve trying to bundle all used pacakges in node_modules. Vite starts analyzing imports and see "@lingui/macro" and starts bundling it. It doesn't know anything about that macro import would be removed from code while transpiling.

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 a pull request may close this issue.

1 participant