example-node-server icon indicating copy to clipboard operation
example-node-server copied to clipboard

Add example of importing local file from a different path

Open dandv opened this issue 9 years ago • 1 comments

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?

dandv avatar Jan 16 '17 15:01 dandv

I'm facing the very same issue. Any suggestion/solution on this would be helpful.

akbaruddink avatar Mar 27 '18 07:03 akbaruddink