Skip to content

Commit ee72546

Browse files
committed
upd
1 parent 2a8eb5d commit ee72546

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

manual/src/manifest.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ com.alpha.lets-go = "1"
154154
com.omega.game = "1"
155155

156156
# NPM dependencies, for internal use
157-
# in Whack Red facade packages.
157+
# in Whack Red projects.
158158
#
159159
[npm-dependencies]
160160
"decimal.js" = "1"
161+
"foo" = { path = "foo" } # file: dependency
161162
```
162163

163164
## Compiler options section

manual/src/npm.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# NPM
2+
3+
Using NPM dependencies consists of basically using `NPM` meta-data over variables and interoperating with these variables using built-in packages like `org.js.g.*`, `org.node.g.*`, `org.node.fs.*` and `org.w3.web.*`.
4+
5+
Note that `NPM` annotatated variables are always `org.js.g.Object` instances that wrap an underlying JavaScript value; it's not entirely reliable to use the `is`, `as`, `T(v)` and `===` operators with them. You may explore these wrapper APIs for more ideas.
6+
7+
```sx
8+
[NPM(importDefault="foo")]
9+
var foo;
10+
[NPM(importAll="foo")]
11+
var foo;
12+
13+
foo.x // org.js.g.Object
14+
```
15+
16+
## Browser and NodeJS distinguishment
17+
18+
Whack Red internally uses RollupJS as a JS bundler + the node-resolve plugin.
19+
20+
- Whack Red intercepts module resolution (through a mini plugin) so that for web builds, `node:` prefixed modules and most of the implicit NodeJS modules (such as `path` and `fs`, that do not exist in `node_modules/` at least (we won't look at import mappings for now)) return an empty object. (If importing `default`, return an empty object too.)
21+
- Whack Red configures node-resolve `browser=true` during web builds.

0 commit comments

Comments
 (0)