Skip to content

Commit 001e872

Browse files
authored
chore: Update plop.load docs regarding async/await requirement in es6 modules
1 parent 973c1ce commit 001e872

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

plop-load.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plop.load
22
=========
33

4-
`plop.load` can be used to load generators, actionTypes, helpers, and partials from a other plopfiles that are in your project or on NPM (`plop-pack`). Example code below.
4+
`plop.load` can be used to load generators, actionTypes, helpers, and partials from a other plopfiles that are in your project or on NPM (`plop-pack`). `plop.load` executes async when used within es6 modules and requires `async/await`. Example code below.
55

66
### plop.load([targets](#targets), [[config](#config)], [[include](#include)])
77

@@ -30,6 +30,14 @@ If `include` is `true` all assets from the target will be included (none if `fal
3030
- **Object:** the include object allows the consumer to rename assets when for use in their own plopfile. the property name in this object is the asset name, the value is the name that will be given to the asset when loaded.
3131

3232
## Examples
33+
*Usage in es6 modules*
34+
```javascript
35+
// plop.load has to be within an async function
36+
export default async function(plop) {
37+
// Use await to actually load the external files
38+
await plop.load('./plopfiles/component.js`);
39+
}
40+
```
3341
*load via a path*
3442
```javascript
3543
// loads all 5 generators, no helpers, actionTypes or partials (even if they exist)
@@ -63,7 +71,6 @@ If `include` is `true` all assets from the target will be included (none if `fal
6371
```javascript
6472
// loads all 3 helpers
6573
plop.load('plop-pack-fancy-comments');
66-
};
6774
```
6875
*load via npm module with a renaming include config*
6976
```javascript

0 commit comments

Comments
 (0)