Skip to content

Instantly share code, notes, and snippets.

@pvdz
Created September 24, 2017 08:54
Show Gist options
  • Save pvdz/488d0db66bd6e23b67a55f6e08a9cf08 to your computer and use it in GitHub Desktop.
Save pvdz/488d0db66bd6e23b67a55f6e08a9cf08 to your computer and use it in GitHub Desktop.
Silly mocha+babel problem with relative imports outside project root
How do you mocha+babel test projectA as is?
Note that projectB also its own mocha+babel tests which run fine (but they do not need to run here).
// ..../somedir/projectA/src/index.js
import {x} from '../../projectB/src/index.js';
...
// ..../somedir/projectB/src/index.js
import {x} from './tools.js';
...
// something like this works for all my projects, including projectB
node_modules/.bin/mocha --compilers js:babel-core/register tests/specs/**/*.js
How do I make it work for projectA without blowing up on the import keyword
in projectB? Note that I explicitly want to import projectB as es6.
@pvdz
Copy link
Author

pvdz commented Sep 25, 2017

The solution was to make sure a .babelrc exists in all folders included this way. One was missing which blew up the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment