1
0

without-imports.js 714 B

12345678910111213141516171819202122
  1. function withImportsExcluded(data) {
  2. var srcLines = data.split(/\r\n|\r|\n/), dstLines = [], doCopy = true;
  3. srcLines.forEach(function (line) {
  4. if (line.replace(/\s/g, '') === '//>>excludeStart("imports",pragmas.excludeImports);') {
  5. doCopy = false;
  6. } else if (line.replace(/\s/g, '') === '//>>excludeEnd("imports");') {
  7. doCopy = true;
  8. } else if (doCopy) {
  9. dstLines.push(line);
  10. }
  11. });
  12. return dstLines.join('\n');
  13. }
  14. define({
  15. load: function (name, req, onload, config) {
  16. req(['text!' + name + '.js'], function (text) {
  17. text = withImportsExcluded(text);
  18. onload.fromText(text);
  19. });
  20. }
  21. });