bare-module 3.1.1 → 3.1.3
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/CMakeLists.txt +1 -1
- package/index.js +17 -5
- package/package.json +2 -4
package/CMakeLists.txt
CHANGED
package/index.js
CHANGED
|
@@ -35,11 +35,11 @@ const Module = module.exports = exports = class Module {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
get filename () {
|
|
38
|
-
return
|
|
38
|
+
return urlToPath(this._url)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
get dirname () {
|
|
42
|
-
return
|
|
42
|
+
return urlToDirname(this._url)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
get type () {
|
|
@@ -473,7 +473,7 @@ exports.createRequire = function createRequire (parentURL, opts = {}) {
|
|
|
473
473
|
|
|
474
474
|
switch (resolved.protocol) {
|
|
475
475
|
case 'builtin:': return resolved.pathname
|
|
476
|
-
default: return
|
|
476
|
+
default: return urlToPath(resolved)
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
|
|
@@ -544,7 +544,7 @@ Module._extensions['.cjs'] = function (module, source, referrer) {
|
|
|
544
544
|
|
|
545
545
|
module._exports = {}
|
|
546
546
|
|
|
547
|
-
const filename =
|
|
547
|
+
const filename = urlToPath(module._url)
|
|
548
548
|
|
|
549
549
|
binding.createFunction(module._url.href, ['require', 'module', 'exports', '__filename', '__dirname'], source, 0)(
|
|
550
550
|
require,
|
|
@@ -567,7 +567,7 @@ Module._extensions['.cjs'] = function (module, source, referrer) {
|
|
|
567
567
|
|
|
568
568
|
switch (resolved.protocol) {
|
|
569
569
|
case 'builtin:': return resolved.pathname
|
|
570
|
-
default:
|
|
570
|
+
default: urlToPath(resolved)
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
|
|
@@ -686,3 +686,15 @@ Bare
|
|
|
686
686
|
|
|
687
687
|
binding.destroy(Module._handle)
|
|
688
688
|
})
|
|
689
|
+
|
|
690
|
+
function urlToPath (u) {
|
|
691
|
+
return u.protocol === 'file:'
|
|
692
|
+
? url.fileURLToPath(u)
|
|
693
|
+
: decodeURIComponent(u.pathname)
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function urlToDirname (u) {
|
|
697
|
+
return u.protocol === 'file:'
|
|
698
|
+
? path.dirname(url.fileURLToPath(u))
|
|
699
|
+
: decodeURIComponent((new URL('.', u)).pathname).replace(/\/$/, '')
|
|
700
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-module",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Module support for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -11,9 +11,7 @@
|
|
|
11
11
|
"lib",
|
|
12
12
|
"prebuilds"
|
|
13
13
|
],
|
|
14
|
-
"addon":
|
|
15
|
-
"target": "bare_module"
|
|
16
|
-
},
|
|
14
|
+
"addon": true,
|
|
17
15
|
"scripts": {
|
|
18
16
|
"test": "standard && bare test.js"
|
|
19
17
|
},
|