You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+13-22Lines changed: 13 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,12 +13,9 @@
13
13
14
14
# val-loader
15
15
16
-
A webpack loader which executes a given module, and returns the result of the
17
-
execution at build-time, when the module is required in the bundle. In this way,
18
-
the loader changes a module from code to a result.
16
+
A webpack loader that executes a given module and returns the result of the execution at build-time, when the module is required in the bundle. In this way, the loader changes a module from code into a result.
19
17
20
-
Another way to view `val-loader`, is that it allows a user a way to make their
21
-
own custom loader logic, without having to write a custom loader.
18
+
Another way to view `val-loader` is that it allows users to implement custom loader logic without needing to write a full custom loader.
22
19
23
20
The target module is called with two arguments: `(options, loaderContext)`
24
21
@@ -41,7 +38,7 @@ yarn add -D val-loader
41
38
pnpm add -D val-loader
42
39
```
43
40
44
-
Then add the loader to your `webpack`config. For example:
41
+
Then, add the loader to your `webpack`configuration. For example:
45
42
46
43
**target-file.js**
47
44
@@ -76,7 +73,7 @@ module.exports = {
76
73
constanswer=require("target-file");
77
74
```
78
75
79
-
And run `webpack` via your preferred method.
76
+
Finally, run `webpack`using the method you normally use (e.g., via CLI or an npm script).
80
77
81
78
## Options
82
79
@@ -92,7 +89,7 @@ type executableFile = string;
92
89
93
90
Default: `undefined`
94
91
95
-
Allows to specify path to the executable file
92
+
Allows to specify path to the executable file.
96
93
97
94
**data.json**
98
95
@@ -148,9 +145,7 @@ module.exports = {
148
145
149
146
## Return Object Properties
150
147
151
-
Targeted modules of this loader must export a `Function` that returns an object,
152
-
or a `Promise` resolving an object (e.g. async function), containing a `code` property at a minimum, but can
153
-
contain any number of additional properties.
148
+
Targeted modules of this loader must export a `function` that returns an object, or a `Promise` resolving to an object (e.g. async function), containing a `code` property at a minimum, but can also include additional properties.
154
149
155
150
### `code`
156
151
@@ -163,7 +158,7 @@ type code = string | Buffer;
163
158
Default: `undefined`
164
159
_Required_
165
160
166
-
Code passed along to webpack or the next loader that will replace the module.
161
+
Code passed along to webpack or the next loader that will replace the original module.
167
162
168
163
### `sourceMap`
169
164
@@ -187,9 +182,7 @@ type ast = Array<object>;
187
182
188
183
Default: `undefined`
189
184
190
-
An [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree)
191
-
that will be passed to the next loader. Useful to speed up the build time if the
192
-
next loader uses the same AST.
185
+
An [Abstract Syntax Tree (AST)](https://en.wikipedia.org/wiki/Abstract_syntax_tree) that will be passed to the next loader. Useful to speed up the build time if the next loader uses the same AST.
193
186
194
187
### `dependencies`
195
188
@@ -243,17 +236,14 @@ type cacheable = boolean;
243
236
244
237
Default: `false`
245
238
246
-
If `true`, specifies that the code can be re-used in watch mode if none of the
247
-
`dependencies` have changed.
239
+
If `true`, specifies that the code can be reused in watch mode if none of the `dependencies` have changed.
248
240
249
241
## Examples
250
242
251
243
### Simple
252
244
253
-
In this example the loader is configured to operator on a file name of
254
-
`years-in-ms.js`, execute the code, and store the result in the bundle as the
255
-
result of the execution. This example passes `years` as an `option`, which
256
-
corresponds to the `years` parameter in the target module exported function:
245
+
In this example the loader is configured to operate on a file name of `years-in-ms.js`, execute the code, and store the result in the bundle as the result of the execution.
246
+
This example passes `years` as an `option`, which corresponds to the `years` parameter in the target module's exported function:
257
247
258
248
**years-in-ms.js**
259
249
@@ -446,7 +436,8 @@ module.exports = {
446
436
447
437
## Contributing
448
438
449
-
Please take a moment to read our contributing guidelines if you haven't yet done so.
439
+
We welcome all contributions!
440
+
If you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.
0 commit comments