functionalscript 0.0.277 → 0.0.278
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commonjs/build/index.js +27 -3
- package/package.json +1 -1
package/commonjs/build/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const function_ = require('../module/function')
|
|
|
4
4
|
const { todo } = require('../../dev')
|
|
5
5
|
const map = require('../../types/map')
|
|
6
6
|
const object = require('../../types/object')
|
|
7
|
-
const
|
|
7
|
+
const path = require('../path')
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @template M
|
|
@@ -47,8 +47,32 @@ const getOrBuild = packageGet => moduleMapInterface => compile => moduleId => {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/** @type {function_.Require<readonly[M, map.Map<string>]>} */
|
|
50
|
-
const require_ =
|
|
51
|
-
|
|
50
|
+
const require_ = pathStr => prior => {
|
|
51
|
+
const pathResult = path.parseAndFind(packageGet)(moduleId.packageId)(moduleIdStr)(pathStr)
|
|
52
|
+
if (pathResult === undefined) { return [['error', `file not found: '${pathStr}'`], prior] }
|
|
53
|
+
const mId = { packageId: pathResult.package, path: pathResult.file.split('/') }
|
|
54
|
+
const [state, newMap] = getOrBuild
|
|
55
|
+
(packageGet)
|
|
56
|
+
(moduleMapInterface)
|
|
57
|
+
(compile)
|
|
58
|
+
(mId)
|
|
59
|
+
(prior[0])
|
|
60
|
+
switch (state[0]) {
|
|
61
|
+
case 'ok': {
|
|
62
|
+
const newRequireMap = map.set(pathStr)(module_.idToString(mId))(prior[1])
|
|
63
|
+
return [
|
|
64
|
+
['ok', state[1].exports],
|
|
65
|
+
[newMap, newRequireMap]
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
case 'building': {
|
|
69
|
+
return todo()
|
|
70
|
+
}
|
|
71
|
+
// 'ok'
|
|
72
|
+
default: {
|
|
73
|
+
return todo()
|
|
74
|
+
}
|
|
75
|
+
}
|
|
52
76
|
}
|
|
53
77
|
|
|
54
78
|
return moduleMapFirst => {
|