Skip to content

Commit d13aa20

Browse files
committed
first working copy
1 parent f3a49d6 commit d13aa20

18 files changed

+5290
-2
lines changed

.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
tests
3+
src

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"arrowParens": "always"
7+
}

README.md

+45-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
1-
# esbuild-plugin-require-context
2-
An esbuild plugin which simulates require.context from webpack.
1+
# esbuild-plugin-import-glob
2+
3+
A esbuild plugin which allows to import multiple files using the glob syntax.
4+
5+
## Basic Usage
6+
7+
1. Install this plugin in your project:
8+
9+
```sh
10+
npm install --save-dev esbuild-plugin-import-glob
11+
```
12+
13+
2. Add this plugin to your esbuild build script:
14+
15+
```diff
16+
+const ImportGlobPlugin = require('esbuild-plugin-import-glob');
17+
...
18+
esbuild.build({
19+
...
20+
plugins: [
21+
+ ImportGlobPlugin(),
22+
],
23+
})
24+
```
25+
26+
3. Use import or require
27+
28+
```typescript
29+
// @ts-ignore
30+
import migrationsArray from './migrations/**/*';
31+
32+
// contains default export
33+
migrationsArray[0].default;
34+
```
35+
36+
```typescript
37+
// @ts-ignore
38+
import * as migrations from './migrations/**/*';
39+
40+
const { default: migrationsArray, filenames } = migrations;
41+
```
42+
43+
```typescript
44+
const { default: migrationsArray, filenames } = require('./migrations/**/*');
45+
```

jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

0 commit comments

Comments
 (0)