3.0.27 • Published 10 months ago

esm-import-directory v3.0.27

Weekly downloads
5
License
MIT
Repository
github
Last release
10 months ago

esm-import-directory

Import a directory of modules using es6 modules import

Usage

import path from 'path';
import importDirectory from 'esm-import-directory';

const __dirname = import.meta.dirname;

(async () => {
  // import as array, eg. [{ hello: 'world' }]
  const typeDefs = await importDirectory(path.join(dirname, 'typeDefs'));

  // import with paths, eg. { 'filename.mjs': { hello: 'world' } }
  const typeDefPaths = await importDirectory(path.join(dirname, 'typeDefs'), {
    paths: true,
  });
})();

Options

  • recursive (boolean) - traverse modules recursively. Default: false.
  • paths (boolean) - modules returned as an object with relative paths vs as an array. Default: false.
  • filename (boolean) - only return the filename without the extension. Default: true for paths.
  • default (boolean) - extract default from es6 modules. Default: true.
  • extensions (array) - the file extension types to process. Default: '.mjs'
3.0.27

10 months ago

3.0.23

11 months ago

3.0.24

11 months ago

3.0.21

11 months ago

3.0.22

11 months ago

3.0.25

11 months ago

3.0.26

11 months ago

3.0.20

11 months ago

3.0.18

11 months ago

3.0.19

11 months ago

3.0.16

11 months ago

3.0.17

11 months ago

3.0.14

11 months ago

3.0.15

11 months ago

3.0.13

11 months ago

3.0.12

11 months ago

3.0.10

11 months ago

3.0.11

11 months ago

2.6.1

12 months ago

3.0.4

11 months ago

3.0.3

11 months ago

3.0.2

11 months ago

3.0.1

11 months ago

3.0.8

11 months ago

3.0.7

11 months ago

3.0.6

11 months ago

3.0.5

11 months ago

3.0.0

12 months ago

2.6.0

1 year ago

2.5.0

2 years ago

2.4.1

3 years ago

2.4.0

4 years ago

2.3.8

5 years ago

2.3.7

5 years ago

2.3.6

6 years ago

2.3.5

6 years ago

2.3.4

6 years ago

2.3.3

6 years ago

2.3.2

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.0.0

6 years ago

1.4.0

7 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago