Skip to content

Commit

Permalink
fix to allow versioned plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Dec 18, 2014
1 parent ca501e8 commit 95a9c6b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/extension-versions.js
Expand Up @@ -245,8 +245,9 @@ function versions(loader) {

// strip the version before applying map config
var stripVersion, stripSubPathLength;
if (name.indexOf('@') > 0) {
var versionIndex = name.lastIndexOf('@');
var pluginIndex = name.lastIndexOf('!');
var versionIndex = (pluginIndex == -1 ? name : name.substr(0, pluginIndex)).lastIndexOf('@');
if (versionIndex > 0) {
var parts = name.substr(versionIndex + 1, name.length - versionIndex - 1).split('/');
stripVersion = parts[0];
stripSubPathLength = parts.length;
Expand Down
11 changes: 10 additions & 1 deletion test/test.js
Expand Up @@ -22,7 +22,7 @@ function err(e) {

var ie8 = typeof navigator != 'undefined' && navigator.appVersion && navigator.appVersion.indexOf('MSIE 8') != -1;

System.traceurOptions = { asyncFunctions: true };
System.traceurOptions.asyncFunctions = true;

asyncTest('Error handling', function() {
System['import']('tests/error-loader').then(err, function(e) {
Expand Down Expand Up @@ -373,6 +373,15 @@ asyncTest('Simple compiler Plugin', function() {
}, err);
});

asyncTest('Versioned plugin', function() {
System.versions['tests/versioned-plugin-test'] = '1.2.3';
System['import']('tests/versioned-plugin-test/main').then(function(m) {
ok(m.output == 'plugin output');
ok(m.versionedPlugin == true);
start();
}, err);
})

asyncTest('Mapping to a plugin', function() {
System.map['pluginrequest'] = 'tests/compiled.coffee!';
System.map['coffee'] = 'tests/compiler-plugin';
Expand Down
3 changes: 3 additions & 0 deletions test/tests/plugin@1.2.3/plugin.js
@@ -0,0 +1,3 @@
exports.translate = function(load) {
load.source += '\nexports.versionedPlugin = true;';
}
1 change: 1 addition & 0 deletions test/tests/versioned-plugin-test@1.2.3/main.js
@@ -0,0 +1 @@
module.exports = require('../compiler-test.coffee!tests/plugin@1.2.3/plugin');

0 comments on commit 95a9c6b

Please sign in to comment.