bare-module 1.14.4 → 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 +17 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -238,12 +238,14 @@ module.exports = exports = class Module {
238
238
 
239
239
  if (this._cache[specifier]) return this._transform(this._cache[specifier], referrer, dynamic)
240
240
 
241
- const bundle = this._bundleFor(path.dirname(specifier), protocol, source)
241
+ const bundle = this._bundleFor(path.dirname(specifier), protocol)
242
242
 
243
243
  if (bundle) {
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
  },
@@ -699,6 +703,8 @@ exports._extensions['.node'] = function (module, source, referrer, protocol, imp
699
703
  }
700
704
 
701
705
  exports._extensions['.bundle'] = function (module, source, referrer, protocol, imports) {
706
+ if (source === null) source = protocol.read(module._filename)
707
+
702
708
  if (typeof source === 'string') source = Buffer.from(source)
703
709
 
704
710
  const bundle = this._bundleFor(module._filename, protocol, source)
@@ -710,8 +716,13 @@ exports._extensions['.bundle'] = function (module, source, referrer, protocol, i
710
716
  }
711
717
 
712
718
  exports._protocols['file:'] = new Protocol({
713
- preresolve (specifier) {
714
- return path.normalize(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
715
726
  },
716
727
 
717
728
  postresolve (specifier) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "1.14.4",
3
+ "version": "1.14.6",
4
4
  "description": "Module support for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [