esperanto-source 0.6.9.1 → 0.6.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56aef57f1e51808d542880756db24d0a32df4925
4
- data.tar.gz: 18be8f6107069789bdce3763c8f11e1d12b6b54b
3
+ metadata.gz: fa2d37c4a2dc23e02b47dd28844b868f49023385
4
+ data.tar.gz: 2ec273351482319b1c82da3c09f8b9a22e05cbe2
5
5
  SHA512:
6
- metadata.gz: 896e3ef4d66992cfd0c43908436c24f0287d6fd79ea389c96102e6ed76d1e83672f4cf306e920c6e484552e9c0d99f7152e3f94e9a8533d1c90c8a2ee973780a
7
- data.tar.gz: 2891c81249d33bdf3a784b9ad26b604a319b685c5ef3486a2da55b25fb6fdd63eba6c1201d59ce64f1b7feb046f628323a9f402df51cdc131a2c02e36be1b5e4
6
+ metadata.gz: e8e61eaab45153c2be2c5458aa21e7b819b52605525ece29b0ca5c7db4fb021fc368308789f516885841a6bba5a051f1ca6d3236575a88ec463b787d23ac0ee6
7
+ data.tar.gz: 8fd331d6f149b88b11160fa3df0e237a6627d9e163fcd4fd5011be63ca28ef88c14448fdc111175427c98d6a39e4c7426a0853540fd7a6edcad7dffcc2857cce
@@ -1,5 +1,5 @@
1
1
  module Esperanto
2
2
  module Source
3
- VERSION = '0.6.9.1'
3
+ VERSION = '0.6.10'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*
2
- esperanto.js v0.6.9 - 2015-02-06
2
+ esperanto.js v0.6.10 - 2015-02-09
3
3
  http://esperantojs.org
4
4
 
5
5
  Released under the MIT License.
@@ -1766,7 +1766,7 @@
1766
1766
  toUmd: transpileMethod( 'umd' ),
1767
1767
 
1768
1768
  bundle: function ( options ) {
1769
- return undefined__default( options ).then( function ( bundle ) {
1769
+ return getBundle( options ).then( function ( bundle ) {
1770
1770
  return {
1771
1771
  imports: bundle.externalModules.map( function(mod ) {return mod.id} ),
1772
1772
  exports: flattenExports( bundle.entryModule.exports ),
data/vendor/esperanto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- esperanto.js v0.6.9 - 2015-02-06
2
+ esperanto.js v0.6.10 - 2015-02-09
3
3
  http://esperantojs.org
4
4
 
5
5
  Released under the MIT License.
@@ -805,7 +805,7 @@ function populateIdentifierReplacements ( bundle ) {
805
805
  // then determine which existing identifiers
806
806
  // need to be replaced
807
807
  bundle.modules.forEach( function(mod ) {
808
- var moduleIdentifiers, x;
808
+ var moduleIdentifiers;
809
809
 
810
810
  moduleIdentifiers = mod.identifierReplacements;
811
811
 
@@ -1179,7 +1179,8 @@ function transformBody__transformBody ( bundle, mod, body ) {var $D$1;
1179
1179
  if ( name === identifierReplacements.default ) {
1180
1180
  body.remove( x.start, x.end );
1181
1181
  } else {
1182
- body.replace( x.start, x.end, (("var " + (identifierReplacements.default)) + (" = " + (identifierReplacements[name])) + ";") );
1182
+ var original = hasOwnProp.call( identifierReplacements, name ) ? identifierReplacements[ name ] : name;
1183
+ body.replace( x.start, x.end, (("var " + (identifierReplacements.default)) + (" = " + original) + ";") );
1183
1184
  }
1184
1185
  }
1185
1186
 
@@ -1360,7 +1361,7 @@ function getModule ( mod ) {var $D$2;
1360
1361
  return mod;
1361
1362
  ;$D$2 = void 0}
1362
1363
 
1363
- var Promise = sander.Promise;
1364
+ var getBundle__Promise = sander.Promise;
1364
1365
 
1365
1366
  function getBundle ( options ) {
1366
1367
  var entry = options.entry.replace( /\.js$/, '' ),
@@ -1377,7 +1378,7 @@ function getBundle ( options ) {
1377
1378
  entry = entry.substring( base.length );
1378
1379
  }
1379
1380
 
1380
- return fetchModule( entry ).then( function() {
1381
+ return fetchModule( entry, null ).then( function() {
1381
1382
  var entryModule, bundle;
1382
1383
 
1383
1384
  entryModule = moduleLookup[ entry ];
@@ -1401,68 +1402,53 @@ function getBundle ( options ) {
1401
1402
  return bundle;
1402
1403
  });
1403
1404
 
1404
- function fetchModule ( moduleId ) {
1405
- var modulePath;
1406
-
1407
- modulePath = path.resolve( base, moduleId + '.js' );
1408
-
1405
+ function fetchModule ( moduleId, importerPath ) {
1409
1406
  if ( !hasOwnProp.call( promiseById, moduleId ) ) {
1410
- promiseById[ moduleId ] = sander.readFile( modulePath ).catch( function ( err ) {
1411
- if ( err.code === 'ENOENT' ) {
1412
- modulePath = modulePath.replace( /\.js$/, '/index.js' );
1413
- return sander.readFile( modulePath );
1414
- }
1407
+ promiseById[ moduleId ] = resolvePath( base, moduleId, importerPath, options.resolvePath ).then( function(modulePath ) {
1408
+ return sander.readFile( modulePath ).then( String ).then( function ( source ) {
1409
+ var module, promises;
1415
1410
 
1416
- throw err;
1417
- }).then( function ( source ) {
1418
- source = String( source );
1419
-
1420
- if ( options.transform ) {
1421
- source = options.transform( source, modulePath );
1411
+ if ( options.transform ) {
1412
+ source = options.transform( source, modulePath );
1422
1413
 
1423
- if ( typeof source !== 'string' && !isThenable( source ) ) {
1424
- throw new Error( 'transform should return String or Promise' );
1414
+ if ( typeof source !== 'string' && !isThenable( source ) ) {
1415
+ throw new Error( 'transform should return String or Promise' );
1416
+ }
1425
1417
  }
1426
- }
1427
1418
 
1428
- return source;
1429
- }).then( function ( source ) {
1430
- var module, promises;
1419
+ module = getModule({
1420
+ source: source,
1421
+ id: moduleId,
1422
+ file: modulePath.substring( base.length ),
1423
+ path: modulePath
1424
+ });
1431
1425
 
1432
- module = getModule({
1433
- source: source,
1434
- id: moduleId,
1435
- file: modulePath.substring( base.length ),
1436
- path: modulePath
1437
- });
1426
+ modules.push( module );
1427
+ moduleLookup[ moduleId ] = module;
1438
1428
 
1439
- modules.push( module );
1440
- moduleLookup[ moduleId ] = module;
1429
+ promises = module.imports.map( function(x ) {
1430
+ x.id = resolveId( x.path, module.file );
1441
1431
 
1442
- promises = module.imports.map( function(x ) {
1443
- x.id = resolveId( x.path, module.file );
1432
+ if ( x.id === moduleId ) {
1433
+ throw new Error( 'A module (' + moduleId + ') cannot import itself' );
1434
+ }
1444
1435
 
1445
- if ( x.id === moduleId ) {
1446
- throw new Error( 'A module (' + moduleId + ') cannot import itself' );
1447
- }
1436
+ // Some modules can be skipped
1437
+ if ( skip && ~skip.indexOf( x.id ) ) {
1438
+ return;
1439
+ }
1448
1440
 
1449
- // Some modules can be skipped
1450
- if ( skip && ~skip.indexOf( x.id ) ) {
1451
- return;
1452
- }
1441
+ // short-circuit cycles
1442
+ if ( hasOwnProp.call( promiseById, x.id ) ) {
1443
+ return;
1444
+ }
1453
1445
 
1454
- // short-circuit cycles
1455
- if ( hasOwnProp.call( promiseById, x.id ) ) {
1456
- return;
1457
- }
1446
+ return fetchModule( x.id, modulePath );
1447
+ });
1458
1448
 
1459
- return fetchModule( x.id );
1449
+ return getBundle__Promise.all( promises );
1460
1450
  });
1461
-
1462
- return Promise.all( promises );
1463
- }).catch( function ( err ) {
1464
- var externalModule;
1465
-
1451
+ }, function ( err ) {
1466
1452
  if ( err.code === 'ENOENT' ) {
1467
1453
  if ( moduleId === entry ) {
1468
1454
  throw new Error( 'Could not find entry module (' + entry + ')' );
@@ -1470,7 +1456,7 @@ function getBundle ( options ) {
1470
1456
 
1471
1457
  // Most likely an external module
1472
1458
  if ( !hasOwnProp.call( externalModuleLookup, moduleId ) ) {
1473
- externalModule = {
1459
+ var externalModule = {
1474
1460
  id: moduleId
1475
1461
  };
1476
1462
 
@@ -1487,6 +1473,26 @@ function getBundle ( options ) {
1487
1473
  }
1488
1474
  }
1489
1475
 
1476
+ function resolvePath ( base, moduleId, importerPath, resolver ) {
1477
+ return tryPath( base + moduleId + '.js' )
1478
+ .catch( function () {
1479
+ return tryPath( base + moduleId + path.sep + 'index.js' );
1480
+ })
1481
+ .catch( function ( err ) {
1482
+ if ( resolver ) {
1483
+ return resolver( moduleId, importerPath );
1484
+ } else {
1485
+ throw err;
1486
+ }
1487
+ });
1488
+ }
1489
+
1490
+ function tryPath ( path ) {
1491
+ return sander.stat( path ).then( function () {
1492
+ return path;
1493
+ });
1494
+ }
1495
+
1490
1496
  function isThenable ( obj ) {
1491
1497
  return obj && typeof obj.then === 'function';
1492
1498
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esperanto-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9.1
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryunosuke SATO