您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. var extensions = {
  2. '.babel.js': [
  3. {
  4. module: '@babel/register',
  5. register: function(hook) {
  6. // register on .js extension due to https://github.com/joyent/node/blob/v0.12.0/lib/module.js#L353
  7. // which only captures the final extension (.babel.js -> .js)
  8. hook({ extensions: '.js' });
  9. },
  10. },
  11. {
  12. module: 'babel-register',
  13. register: function(hook) {
  14. hook({ extensions: '.js' });
  15. },
  16. },
  17. {
  18. module: 'babel-core/register',
  19. register: function(hook) {
  20. hook({ extensions: '.js' });
  21. },
  22. },
  23. {
  24. module: 'babel/register',
  25. register: function(hook) {
  26. hook({ extensions: '.js' });
  27. },
  28. },
  29. ],
  30. '.babel.ts': [
  31. {
  32. module: '@babel/register',
  33. register: function(hook) {
  34. hook({ extensions: '.ts' });
  35. },
  36. },
  37. ],
  38. '.buble.js': 'buble/register',
  39. '.cirru': 'cirru-script/lib/register',
  40. '.cjsx': 'node-cjsx/register',
  41. '.co': 'coco',
  42. '.coffee': ['coffeescript/register', 'coffee-script/register', 'coffeescript', 'coffee-script'],
  43. '.coffee.md': ['coffeescript/register', 'coffee-script/register', 'coffeescript', 'coffee-script'],
  44. '.csv': 'require-csv',
  45. '.eg': 'earlgrey/register',
  46. '.esm.js': {
  47. module: 'esm',
  48. register: function(hook) {
  49. // register on .js extension due to https://github.com/joyent/node/blob/v0.12.0/lib/module.js#L353
  50. // which only captures the final extension (.babel.js -> .js)
  51. var esmLoader = hook(module);
  52. require.extensions['.js'] = esmLoader('module')._extensions['.js'];
  53. },
  54. },
  55. '.iced': ['iced-coffee-script/register', 'iced-coffee-script'],
  56. '.iced.md': 'iced-coffee-script/register',
  57. '.ini': 'require-ini',
  58. '.js': null,
  59. '.json': null,
  60. '.json5': 'json5/lib/require',
  61. '.jsx': [
  62. {
  63. module: '@babel/register',
  64. register: function(hook) {
  65. hook({ extensions: '.jsx' });
  66. },
  67. },
  68. {
  69. module: 'babel-register',
  70. register: function(hook) {
  71. hook({ extensions: '.jsx' });
  72. },
  73. },
  74. {
  75. module: 'babel-core/register',
  76. register: function(hook) {
  77. hook({ extensions: '.jsx' });
  78. },
  79. },
  80. {
  81. module: 'babel/register',
  82. register: function(hook) {
  83. hook({ extensions: '.jsx' });
  84. },
  85. },
  86. {
  87. module: 'node-jsx',
  88. register: function(hook) {
  89. hook.install({ extension: '.jsx', harmony: true });
  90. },
  91. },
  92. ],
  93. '.litcoffee': ['coffeescript/register', 'coffee-script/register', 'coffeescript', 'coffee-script'],
  94. '.liticed': 'iced-coffee-script/register',
  95. '.ls': ['livescript', 'LiveScript'],
  96. '.node': null,
  97. '.toml': {
  98. module: 'toml-require',
  99. register: function(hook) {
  100. hook.install();
  101. },
  102. },
  103. '.ts': [
  104. 'ts-node/register',
  105. 'typescript-node/register',
  106. 'typescript-register',
  107. 'typescript-require',
  108. {
  109. module: '@babel/register',
  110. register: function(hook) {
  111. hook({ extensions: '.ts' });
  112. },
  113. },
  114. ],
  115. '.tsx': [
  116. 'ts-node/register',
  117. 'typescript-node/register',
  118. {
  119. module: '@babel/register',
  120. register: function(hook) {
  121. hook({ extensions: '.tsx' });
  122. },
  123. },
  124. ],
  125. '.wisp': 'wisp/engine/node',
  126. '.xml': 'require-xml',
  127. '.yaml': 'require-yaml',
  128. '.yml': 'require-yaml',
  129. };
  130. var jsVariantExtensions = [
  131. '.js',
  132. '.babel.js',
  133. '.babel.ts',
  134. '.buble.js',
  135. '.cirru',
  136. '.cjsx',
  137. '.co',
  138. '.coffee',
  139. '.coffee.md',
  140. '.eg',
  141. '.esm.js',
  142. '.iced',
  143. '.iced.md',
  144. '.jsx',
  145. '.litcoffee',
  146. '.liticed',
  147. '.ls',
  148. '.ts',
  149. '.tsx',
  150. '.wisp',
  151. ];
  152. module.exports = {
  153. extensions: extensions,
  154. jsVariants: jsVariantExtensions.reduce(function(result, ext) {
  155. result[ext] = extensions[ext];
  156. return result;
  157. }, {}),
  158. };