index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path')) :
  3. typeof define === 'function' && define.amd ? define(['path'], factory) :
  4. (global.index = factory(global.path));
  5. }(this, (function (path) { 'use strict';
  6. path = 'default' in path ? path['default'] : path;
  7. var index = function (context, ref) {
  8. if ( ref === void 0 ) ref = {};
  9. var useBuiltIns = ref.useBuiltIns;
  10. var env = process.env.BABEL_ENV || process.env.NODE_ENV;
  11. var presets = [
  12. env === 'test' ?
  13. [require('babel-preset-env').default, {
  14. targets: {
  15. node: 'current'
  16. }
  17. }] :
  18. [require('babel-preset-env').default, {
  19. useBuiltIns: useBuiltIns,
  20. modules: false,
  21. targets: {
  22. ie: 9,
  23. uglify: true
  24. }
  25. }],
  26. // vue jsx
  27. require.resolve('babel-preset-vue')
  28. ];
  29. var plugins = [
  30. // Polyfills the runtime needed for async/await and generators
  31. [require.resolve('babel-plugin-transform-runtime'), {
  32. helpers: !useBuiltIns,
  33. polyfill: !useBuiltIns,
  34. regenerator: true,
  35. // Resolve the Babel runtime relative to the config.
  36. moduleName: path.dirname(require.resolve('babel-runtime/package'))
  37. }],
  38. [require('babel-plugin-transform-object-rest-spread'), {
  39. useBuiltIns: useBuiltIns
  40. }],
  41. // For dynamic import that you will use a lot in code-split
  42. require.resolve('babel-plugin-syntax-dynamic-import')
  43. ];
  44. return {
  45. presets: presets,
  46. plugins: plugins
  47. }
  48. };
  49. return index;
  50. })));