Skip to content

Commit 1a9861e

Browse files
committed
Add notes about spec-relative module ids
1 parent 1ae300d commit 1a9861e

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

docs/components.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ define({
9797

9898
## module
9999

100-
The module factory loads an AMD module, *but does not call it*. The module is used directly as the component.
100+
The module factory loads a module, *but does not call it*. The module is used directly as the component.
101101

102102
### Syntax
103103
```javascript
@@ -106,9 +106,46 @@ myComponent: {
106106
}
107107
```
108108

109+
Wire.js uses your existing module loader, such as curl.js, RequireJS, or Node.js's built-in `require` to load modules. You can use any modules formats (AMD, CommonJS, etc.) supported by your loader, including AMD plugins in an AMD environment.
110+
111+
### A note on module ids
112+
113+
Wire.js supports *spec-relative module ids*. This means you can specify modules relative to the current wire spec. For example, if your project looks like:
114+
115+
```text
116+
index.html
117+
app/
118+
spec.js
119+
aModule.js
120+
stuff/
121+
anotherModule.js
122+
...
123+
```
124+
125+
In `spec.js`, you can use relative module ids to reference `aModule` and `anotherModule`:
126+
127+
```js
128+
// app/spec.js
129+
define({
130+
// Use module id relative to spec.js
131+
a: {
132+
module: './aModule'
133+
},
134+
135+
// Relative ids work in create, too
136+
another: {
137+
create: {
138+
module: './stuff/anotherModule'
139+
}
140+
}
141+
});
142+
```
143+
144+
Using relative module ids can make wire specs a bit more terse, and can also ease refactoring when moving a group of related files, which may include a wire spec, around in your project.
145+
109146
## create
110147

111-
The create factory loads an AMD module and uses it to create a component instance by calling the module either as a constructor using `new` or as a regular function, or by begetting a new instance if the module is an object.
148+
The create factory loads a module and uses it to create a component instance by calling the module either as a constructor using `new` or as a regular function, or by begetting a new instance if the module is an object.
112149

113150
### Full syntax
114151

0 commit comments

Comments
 (0)