Skip to content

Commit

Permalink
first working copy
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaschaaf committed Mar 13, 2021
1 parent f3a49d6 commit d13aa20
Show file tree
Hide file tree
Showing 18 changed files with 5,290 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
tests
src
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"arrowParens": "always"
}
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# esbuild-plugin-require-context
An esbuild plugin which simulates require.context from webpack.
# esbuild-plugin-import-glob

A esbuild plugin which allows to import multiple files using the glob syntax.

## Basic Usage

1. Install this plugin in your project:

```sh
npm install --save-dev esbuild-plugin-import-glob
```

2. Add this plugin to your esbuild build script:

```diff
+const ImportGlobPlugin = require('esbuild-plugin-import-glob');
...
esbuild.build({
...
plugins: [
+ ImportGlobPlugin(),
],
})
```

3. Use import or require

```typescript
// @ts-ignore
import migrationsArray from './migrations/**/*';

// contains default export
migrationsArray[0].default;
```

```typescript
// @ts-ignore
import * as migrations from './migrations/**/*';

const { default: migrationsArray, filenames } = migrations;
```

```typescript
const { default: migrationsArray, filenames } = require('./migrations/**/*');
```
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
Loading

0 comments on commit d13aa20

Please sign in to comment.