-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #988 Pass layer module ID and path to builder write method
- Loading branch information
Showing
5 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
define('util',[],function () { | ||
function upper(text) { | ||
return text.toUpperCase(); | ||
}; | ||
|
||
return upper; | ||
}); | ||
|
||
if (typeof define === 'function' && define.amd) { | ||
define('converter',['util'], function (util) { | ||
|
||
return { | ||
version: '2', | ||
convert: function (text) { | ||
return util(text); | ||
} | ||
}; | ||
}); | ||
}; | ||
define('plug',['converter'], function (converter) { | ||
var buildMap = {}; | ||
|
||
function jsEscape(content) { | ||
return content.replace(/(['\\])/g, '\\$1') | ||
.replace(/[\f]/g, "\\f") | ||
.replace(/[\b]/g, "\\b") | ||
.replace(/[\n]/g, "\\n") | ||
.replace(/[\t]/g, "\\t") | ||
.replace(/[\r]/g, "\\r"); | ||
} | ||
|
||
return { | ||
version: '1', | ||
load: function (name, require, onLoad, config) { | ||
var converted = converter.convert(name); | ||
buildMap[name] = converted; | ||
onLoad(converted); | ||
}, | ||
|
||
write: function (pluginName, moduleName, write, data) { | ||
if (moduleName in buildMap) { | ||
var content = jsEscape(buildMap[moduleName]); | ||
write("define('" + pluginName + "!" + moduleName + | ||
"', function () { /* name: " + data.name + " path: " + data.path.split(/[\/\\]/).pop() + " */ return '" + content + "';});\n"); | ||
} | ||
} | ||
}; | ||
}); | ||
|
||
|
||
define('plug!shouldbeuppercasetext', function () { /* name: plug path: main-builtPluginFirst.js */ return 'SHOULDBEUPPERCASETEXT';}); | ||
|
||
require(['plug', 'converter', 'plug!shouldbeuppercasetext'], | ||
function (plug, converter, text) { | ||
console.log('plugin version: ' + plug.version); | ||
console.log('converter version: ' + converter.version); | ||
console.log('converted text: ' + text); | ||
}); | ||
|
||
define("main", function(){}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters