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.
<p>Executes the given module to generate source code on build time.<p>
18
+
</div>
19
+
20
+
<h2align="center">Install</h2>
21
+
22
+
```bash
23
+
npm install val-loader --save-dev
24
+
```
25
25
26
26
<h2align="center">Examples</h2>
27
27
@@ -66,11 +66,11 @@ function findAnswer(options) {
66
66
returnask(options.question)
67
67
.then(generateResult)
68
68
.then(result=> ({
69
-
69
+
70
70
code:result.code,
71
71
sourceMap:result.sourceMap,
72
72
ast:result.abstractSyntaxTree,
73
-
73
+
74
74
// Mark dependencies of findAnswer().
75
75
// The function will be re-executed if one of these
76
76
// dependencies has changed in watch mode.
@@ -79,7 +79,7 @@ function findAnswer(options) {
79
79
require.resolve('./ask.js'),
80
80
require.resolve('./generateResult.js')
81
81
],
82
-
82
+
83
83
// Flag the generated code as cacheable.
84
84
// If none of the dependencies have changed,
85
85
// the function won't be executed again.
@@ -108,7 +108,7 @@ module.exports = {
108
108
}
109
109
};
110
110
```
111
-
111
+
112
112
<h2align="center">Usage</h2>
113
113
114
114
The module that is loaded with this loader must stick to the following interfaces:
@@ -141,47 +141,47 @@ Property | Type | Description
141
141
`code` | `string|Buffer` | **Required**. The code that is passed to the next loader or to webpack.
142
142
`sourceMap` | [`SourceMap`](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit) | **Optional**. Will be passed to the next loader or to webpack.
143
143
`ast` | `any` | **Optional**. An [Abstract Syntax Tree](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.
144
-
`dependencies` | `Array<string>` | **Default: `[]`**. An array of absolute, native paths to file dependencies that need to be watched for changes.
144
+
`dependencies` | `Array<string>` | **Default: `[]`**. An array of absolute, native paths to file dependencies that need to be watched for changes.
145
145
`cacheable` | `boolean` | **Default: `false`**. Flag whether the code can be re-used in watch mode if none of the `dependencies` have changed.
146
-
146
+
147
147
### Loader Options
148
148
149
-
The **val-loader** itself has no options. The options are passed as they are (without cloning them) to the exported function.
0 commit comments