Open ianxm opened 3 years ago
Looks like the process is launched in the current working directory determined by org. Just use the :dir
header
:dir
didn't make a difference for me. the source is still written to the babel temp dir. here is the example I was using:
#+begin_src typescript :results output silent :dir "."
import * as _ from 'lodash';
const a = [1, 2, 3];
const b = _.map(a, (ii:number) => ii*2);
console.log(`b=${b}`);
#+end_src
this is the output
Wrote /tmp/babel-jk3z45/ob-input-NVa2oo
"../../../../../tmp/babel-jk3z45/ts-src-VYAJVk.ts(1,1): error TS6131: Cannot compile modules using option ’out’ unless the ’--module’ flag is ’amd’ or ’system’.
../../../../../tmp/babel-jk3z45/ts-src-VYAJVk.ts(1,20): error TS2307: Cannot find module ’lodash’ or its corresponding type declarations.
"
I'm not affiliated with this project, but because I commented above I'm getting notifications. One thing that I've done in node blocks is something like require.paths.push('/absolute/path/to/my/modules')
before any imports and this has worked. You can then put it in a :prologue
and store it at the headline level so yo don't have to type it over and over.
I don't remember the exact syntax (but this should be close) as I'm on my work computer, and I've only used it in node, never with ob-typescript, but in theory that should work.
Is there any support for imports? It looks like execution always happens in the babel-temporary-directory so even if there are installed packages where the org file is located, they will not be found. Is there a workaround?