bare-module 4.5.2 → 4.6.0
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/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* global Bare */
|
|
2
2
|
const path = require('bare-path')
|
|
3
3
|
const resolve = require('bare-module-resolve')
|
|
4
|
+
const lex = require('bare-module-lexer')
|
|
4
5
|
const { isURL, fileURLToPath, pathToFileURL } = require('bare-url')
|
|
5
6
|
const Bundle = require('bare-bundle')
|
|
6
|
-
const { parse } = require('cjs-module-lexer')
|
|
7
7
|
const Protocol = require('./lib/protocol')
|
|
8
8
|
const constants = require('./lib/constants')
|
|
9
9
|
const errors = require('./lib/errors')
|
|
@@ -149,21 +149,23 @@ const Module = module.exports = exports = class Module {
|
|
|
149
149
|
|
|
150
150
|
switch (module._type) {
|
|
151
151
|
case constants.types.SCRIPT: {
|
|
152
|
-
const result =
|
|
152
|
+
const result = lex(module._function.toString())
|
|
153
153
|
|
|
154
|
-
for (const name of result.exports) names.add(name)
|
|
154
|
+
for (const { name } of result.exports) names.add(name)
|
|
155
155
|
|
|
156
156
|
const referrer = module
|
|
157
157
|
|
|
158
|
-
for (const specifier of result.
|
|
159
|
-
|
|
158
|
+
for (const { specifier, type } of result.imports) {
|
|
159
|
+
if (type & lex.constants.REEXPORT) {
|
|
160
|
+
const resolved = Module.resolve(specifier, referrer._url, { isImport: true, referrer })
|
|
160
161
|
|
|
161
|
-
|
|
162
|
+
const module = Module.load(resolved, { isImport: true, referrer })
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
if (module._names) {
|
|
165
|
+
for (const name of module._names) names.add(name)
|
|
166
|
+
} else {
|
|
167
|
+
queue.push(module)
|
|
168
|
+
}
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
171
|
|
|
@@ -434,7 +436,7 @@ const Module = module.exports = exports = class Module {
|
|
|
434
436
|
|
|
435
437
|
const resolved = protocol.preresolve(specifier, parentURL)
|
|
436
438
|
|
|
437
|
-
const [resolution] = protocol.resolve(
|
|
439
|
+
const [resolution] = protocol.resolve(resolved, parentURL, imports)
|
|
438
440
|
|
|
439
441
|
if (resolution) return protocol.postresolve(resolution)
|
|
440
442
|
|
|
@@ -487,14 +489,20 @@ const Module = module.exports = exports = class Module {
|
|
|
487
489
|
conditions = referrer ? referrer._conditions : self._conditions
|
|
488
490
|
} = opts
|
|
489
491
|
|
|
490
|
-
const
|
|
492
|
+
const resolved = protocol.preresolve(specifier, parentURL)
|
|
493
|
+
|
|
494
|
+
const [resolution] = protocol.resolve(resolved, parentURL, imports)
|
|
495
|
+
|
|
496
|
+
if (resolution) return protocol.postresolve(resolution)
|
|
497
|
+
|
|
498
|
+
for (const resolution of resolve(resolved, parentURL, {
|
|
491
499
|
conditions: ['asset', ...conditions],
|
|
492
500
|
imports,
|
|
493
501
|
resolutions
|
|
494
|
-
}, readPackage)
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
502
|
+
}, readPackage)) {
|
|
503
|
+
if (protocol.exists(resolution)) {
|
|
504
|
+
return protocol.postresolve(protocol.asset ? protocol.asset(resolution) : resolution)
|
|
505
|
+
}
|
|
498
506
|
}
|
|
499
507
|
|
|
500
508
|
let msg = `Cannot find asset '${specifier}'`
|
package/lib/protocol.js
CHANGED
|
@@ -7,6 +7,7 @@ module.exports = class ModuleProtocol {
|
|
|
7
7
|
'exists',
|
|
8
8
|
'read',
|
|
9
9
|
'load',
|
|
10
|
+
'addon',
|
|
10
11
|
'asset'
|
|
11
12
|
]) {
|
|
12
13
|
const method = methods[name]
|
|
@@ -41,6 +42,10 @@ module.exports = class ModuleProtocol {
|
|
|
41
42
|
return null
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
addon (url) {
|
|
46
|
+
return url
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
asset (url) {
|
|
45
50
|
return url
|
|
46
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-module",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Module support for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"homepage": "https://github.com/holepunchto/bare-module#readme",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"bare-bundle": "^1.3.0",
|
|
30
|
-
"bare-module-
|
|
30
|
+
"bare-module-lexer": "^1.0.0",
|
|
31
|
+
"bare-module-resolve": "^1.8.0",
|
|
31
32
|
"bare-path": "^3.0.0",
|
|
32
|
-
"bare-url": "^2.0.1"
|
|
33
|
-
"cjs-module-lexer": "^1.2.3"
|
|
33
|
+
"bare-url": "^2.0.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"brittle": "^3.1.1",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|