polyfills.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Taken from https://github.com/ionic-team/rollup-plugin-node-polyfills/blob/master/src/modules.ts
  2. const EMPTY_PATH = require.resolve('rollup-plugin-node-polyfills/polyfills/empty.js');
  3. export function builtinsPolyfills() {
  4. const libs = new Map();
  5. libs.set('process', require.resolve('rollup-plugin-node-polyfills/polyfills/process-es6'));
  6. libs.set('buffer', require.resolve('rollup-plugin-node-polyfills/polyfills/buffer-es6'));
  7. libs.set('util', require.resolve('rollup-plugin-node-polyfills/polyfills/util'));
  8. libs.set('sys', libs.get('util'));
  9. libs.set('events', require.resolve('rollup-plugin-node-polyfills/polyfills/events'));
  10. libs.set('stream', require.resolve('rollup-plugin-node-polyfills/polyfills/stream'));
  11. libs.set('path', require.resolve('rollup-plugin-node-polyfills/polyfills/path'));
  12. libs.set('querystring', require.resolve('rollup-plugin-node-polyfills/polyfills/qs'));
  13. libs.set('punycode', require.resolve('rollup-plugin-node-polyfills/polyfills/punycode'));
  14. libs.set('url', require.resolve('rollup-plugin-node-polyfills/polyfills/url'));
  15. libs.set('string_decoder', require.resolve('rollup-plugin-node-polyfills/polyfills/string-decoder'));
  16. libs.set('http', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
  17. libs.set('https', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
  18. libs.set('os', require.resolve('rollup-plugin-node-polyfills/polyfills/os'));
  19. libs.set('assert', require.resolve('rollup-plugin-node-polyfills/polyfills/assert'));
  20. libs.set('constants', require.resolve('rollup-plugin-node-polyfills/polyfills/constants'));
  21. libs.set('_stream_duplex', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/duplex'));
  22. libs.set('_stream_passthrough', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough'));
  23. libs.set('_stream_readable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/readable'));
  24. libs.set('_stream_writable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/writable'));
  25. libs.set('_stream_transform', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/transform'));
  26. libs.set('timers', require.resolve('rollup-plugin-node-polyfills/polyfills/timers'));
  27. libs.set('console', require.resolve('rollup-plugin-node-polyfills/polyfills/console'));
  28. libs.set('vm', require.resolve('rollup-plugin-node-polyfills/polyfills/vm'));
  29. libs.set('zlib', require.resolve('rollup-plugin-node-polyfills/polyfills/zlib'));
  30. libs.set('tty', require.resolve('rollup-plugin-node-polyfills/polyfills/tty'));
  31. libs.set('domain', require.resolve('rollup-plugin-node-polyfills/polyfills/domain'));
  32. // not shimmed
  33. libs.set('dns', EMPTY_PATH);
  34. libs.set('dgram', EMPTY_PATH);
  35. libs.set('child_process', EMPTY_PATH);
  36. libs.set('cluster', EMPTY_PATH);
  37. libs.set('module', EMPTY_PATH);
  38. libs.set('net', EMPTY_PATH);
  39. libs.set('readline', EMPTY_PATH);
  40. libs.set('repl', EMPTY_PATH);
  41. libs.set('tls', EMPTY_PATH);
  42. libs.set('fs', EMPTY_PATH);
  43. libs.set('crypto', EMPTY_PATH);
  44. // libs.set(
  45. // 'fs',
  46. // require.resolve('rollup-plugin-node-polyfills/polyfills/browserify-fs'),
  47. // )
  48. // TODO enable crypto and fs https://github.com/ionic-team/rollup-plugin-node-polyfills/issues/20
  49. // libs.set(
  50. // 'crypto',
  51. // require.resolve(
  52. // 'rollup-plugin-node-polyfills/polyfills/crypto-browserify',
  53. // ),
  54. // )
  55. return libs;
  56. }
  57. //# sourceMappingURL=polyfills.js.map