bare-module 1.14.5 → 1.14.6

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.
Files changed (2) hide show
  1. package/index.js +14 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -244,6 +244,8 @@ module.exports = exports = class Module {
244
244
  protocol = new Protocol({
245
245
  imports: bundle.imports,
246
246
 
247
+ preresolve: this._protocols['file:'].preresolve,
248
+
247
249
  exists (filename) {
248
250
  return bundle.exists(filename)
249
251
  },
@@ -312,6 +314,8 @@ module.exports = exports = class Module {
312
314
  protocol = new Protocol({
313
315
  imports: bundle.imports,
314
316
 
317
+ preresolve: this._protocols['file:'].preresolve,
318
+
315
319
  exists (filename) {
316
320
  return bundle.exists(filename)
317
321
  },
@@ -349,9 +353,7 @@ module.exports = exports = class Module {
349
353
  yield specifier
350
354
  }
351
355
 
352
- if (/^([a-z]:)?([/\\]|\.{1,2}[/\\]?)/i.test(specifier)) {
353
- if (specifier[0] === '.') specifier = path.join(dirname, specifier)
354
-
356
+ if (path.isAbsolute(specifier)) {
355
357
  yield * this._resolveFile(specifier, protocol)
356
358
  yield * this._resolveDirectory(specifier, protocol)
357
359
  }
@@ -541,6 +543,8 @@ module.exports = exports = class Module {
541
543
  protocol = new Protocol({
542
544
  imports: parent.imports,
543
545
 
546
+ preresolve: this._protocols['file:'].preresolve,
547
+
544
548
  exists (filename) {
545
549
  return parent.exists(filename)
546
550
  },
@@ -712,8 +716,13 @@ exports._extensions['.bundle'] = function (module, source, referrer, protocol, i
712
716
  }
713
717
 
714
718
  exports._protocols['file:'] = new Protocol({
715
- preresolve (specifier) {
716
- return specifier.replace(/^file:/, '')
719
+ preresolve (specifier, dirname) {
720
+ specifier = specifier.replace(/^file:/, '')
721
+
722
+ if (specifier[0] === '.') specifier = path.join(dirname, specifier)
723
+ if (specifier[0] === '/' || specifier[0] === '\\') specifier = path.normalize(specifier)
724
+
725
+ return specifier
717
726
  },
718
727
 
719
728
  postresolve (specifier) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "1.14.5",
3
+ "version": "1.14.6",
4
4
  "description": "Module support for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [