How do you get the thread to work with the babel module alias?

I am trying to get the stream type to check my code, but it gives me an error when it cannot find the paths that were rewritten using the alias babel-plugin-module.

I tried unsuccessfully to use the resolve_dirname parameter in the flowconfig file.

Can someone tell me if this babel plugin can be used with a stream?

.babelrc

{ "plugins": [ "transform-flow-strip-types", ["module-alias", [ { "src": "./app", "expose": "app" }, ]] ] } 

.flowconfig

 [options] module.system.node.resolve_dirname=app 

application / main.js

 import bar from 'app/foo'; 

Application / main.js: 3

  3: import bar from 'app/foo'; ^^^^^^^^^^ app/foo. Required module not found 
+8
babel flowtype
source share
2 answers

module.system.node.resolve_dirname actually tells Flow where to start resolving things. If you want the stream to be allowed starting with the "application", you need to specify it in one directory higher than in the application.

Alternatively, you can also use `module.name_mapper = '^ app / ([azA-Z0-9 $ _ /] +) $' → 'src / \ 1'

+1
source share

Here's how to do this when setting up module.name_mapper in .flowconfig [options] . Works in stream version 0.56.0

 module.name_mapper='^app/\([-a-zA-Z0-9$_/]+\)$' -> '<PROJECT_ROOT>/src/\1' 
0
source share

All Articles