Skip to content

Commit 7ab27ca

Browse files
docs: improve (#48)
1 parent 7829c1b commit 7ab27ca

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

README.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ $ npm install exports-loader --save-dev
3434

3535
### Inline
3636

37-
Then add the loader to the desired `import` statemtnt and `require` calls. For example:
37+
The `|` or `%20` (space) allow to separate the `syntax`, `name` and `alias` of export.
38+
The documentation and syntax examples can be read [here](#syntax).
39+
40+
> `%20` is space in a query string, because you can't use spaces in URLs
41+
42+
Then add the loader to the desired `import` statement or `require` calls. For example:
3843

3944
```js
4045
import { myFunction } from 'exports-loader?exports=myFunction!./file.js';
4146
// Adds the following code to the file's source:
4247
//
48+
// ...
49+
// Code
50+
// ...
51+
//
4352
// export { myFunction }
4453

4554
myFunction('Hello world');
@@ -52,6 +61,10 @@ import {
5261
} from 'exports-loader?exports[]=myVariable&exports[]=myFunction!./file.js';
5362
// Adds the following code to the file's source:
5463
//
64+
// ...
65+
// Code
66+
// ...
67+
//
5568
// export { myVariable, myFunction };
5669

5770
const newVariable = myVariable + '!!!';
@@ -65,6 +78,10 @@ myFunction('Hello world');
6578
import { file } from 'exports-loader?[name]!./file.js';
6679
// Adds the following code to the file's source:
6780
//
81+
// ...
82+
// Code
83+
// ...
84+
//
6885
// export { file };
6986

7087
file('string');
@@ -76,22 +93,26 @@ const {
7693
} = require('exports-loader?type=commonjs&exports=myFunction!./file.js');
7794
// Adds the following code to the file's source:
7895
//
96+
// ...
97+
// Code
98+
// ...
99+
//
79100
// module.exports = { myFunction }
80101

81102
myFunction('Hello world');
82103
```
83104

84-
The `|` or `%20` (space) allow to separate the [`syntax`](#syntax), [`name`](#name) and [`alias`](#alias) of export.
85-
86-
> `%20` is space in a query string, because you can't use spaces in URLs
87-
88105
```js
89106
// Alternative syntax:
90107
// import myFunction from 'exports-loader?exports=default%20myFunction!./file.js';
91108
import myFunction from 'exports-loader?exports=default|myFunction!./file.js';
92109
// `%20` is space in a query string, equivalently `default myFunction`
93110
// Adds the following code to the file's source:
94111
//
112+
// ...
113+
// Code
114+
// ...
115+
//
95116
// exports default myFunction;
96117

97118
myFunction('Hello world');
@@ -102,6 +123,10 @@ const myFunction = require('exports-loader?type=commonjs&exports=single|myFuncti
102123
// `|` is separator in a query string, equivalently `single|myFunction`
103124
// Adds the following code to the file's source:
104125
//
126+
// ...
127+
// Code
128+
// ...
129+
//
105130
// module.exports = myFunction;
106131

107132
myFunction('Hello world');
@@ -112,6 +137,10 @@ import { myFunctionAlias } from 'exports-loader?exports=named|myFunction|myFunct
112137
// `|` is separator in a query string, equivalently `named|myFunction|myFunctionAlias`
113138
// Adds the following code to the file's source:
114139
//
140+
// ...
141+
// Code
142+
// ...
143+
//
115144
// exports { myFunction as myFunctionAlias };
116145

117146
myFunctionAlias('Hello world');
@@ -234,9 +263,7 @@ Allows to use a string to describe an export.
234263

235264
##### `Syntax`
236265

237-
The `" "` or `|` (space) separate command parts.
238-
239-
String values let you specify export syntax, name and alias.
266+
The `|` or `%20` (space) allow to separate the `syntax`, `name` and `alias` of export.
240267

241268
String syntax - `[[syntax] [name] [alias]]` or `[[syntax]|[name]|[alias]]`, where:
242269

0 commit comments

Comments
 (0)