4

I have cloned this library and in this library they are using an import with a double astrix, like this:

import * as Areas from './areas/**/planner-element.jsx';

Can anyone explain what is this ** and what it does ?

Liam
  • 27,717
  • 28
  • 128
  • 190
  • It's a globstar – Alexander Feb 01 '18 at 10:59
  • It depends entirely on what's processing that import. It would be meaningless in a browser per current spec, for instance, but presumably you're using Webpack or Browserify or something. – T.J. Crowder Feb 01 '18 at 10:59
  • 6
    Possible duplicate of [Two asterisks in file path](https://stackoverflow.com/questions/8532929/two-asterisks-in-file-path) – Liam Feb 01 '18 at 11:01
  • also duplicate of [Meaning of a double star (**) in a file path](https://stackoverflow.com/questions/46547540/meaning-of-a-double-star-in-a-file-path) – Liam Feb 01 '18 at 11:04
  • Thanks for the reply but I am getting this error ./src/catalog/mycatalog.js Module not found: Can't resolve './holes/**/planner-element.jsx' in '/Users/syookdeveloper/Syook/syook-tnt-client/src/catalog' Do I need to install something to use ** ? – Rachit Aggarwal Feb 01 '18 at 11:07
  • That is a different question, one question at a time please – Liam Feb 01 '18 at 11:08

4 Answers4

4

It's a pattern to identify folders and sub-folders recursively.

For example if they have something like

areas/foo/planner-element.jsx
areas/foo/bar/planner-element.jsx

It will identify both of them. It's like a more loose notation, so it's not really important where that file is, just that it's somewhere under areas

Raul Rene
  • 10,014
  • 9
  • 53
  • 75
1

\**\ This pattern is used for recursive folder tree traversal.

Check out this SO answer

Martin
  • 4,042
  • 2
  • 19
  • 29
0

./lines/**/planner-element.jsx translates to the file planner-element.jsx in any directory under the lines directory. A single asterisk translates to any character up the first / (so ./lines/*.jsx will include all jsx files in the lines directory). A double asterisk translates to any character, which means not only file names but also directories are taken into account (and so ./lines/**/planner-element.jsx will include any file named planner-element.jsx which is in any direrctory underneath the lines directory)

Dan
  • 37
  • 8
-1

** denotes folder any folder names in the path and also can be mutiple child folders.

Eftakhar
  • 455
  • 4
  • 17