example-node-server
example-node-server copied to clipboard
Add example of importing local file from a different path
Say index.js imports a date utility function from ../utils/date. If we run babel-node lib/index/js, that will work. But the serve script, node dist/index.js will no longer work, because utils/date.js has an export statement, which Babel didn't transpile.
We could have utils/src/date.js transpiled to utils/lib/date.js, but then index.js needs to be changed to explicitly import utils/lib/date, and babel-node lib/index.js alone will no longer work correctly for development because utils/lib/date.js is outdated vs. utils/src/date.js.
@thejameskyle, what would be the best practice here?
I'm facing the very same issue. Any suggestion/solution on this would be helpful.