index.js 908 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _path = require('path');
  6. var _path2 = _interopRequireDefault(_path);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. const getWorker = (file, content, options) => {
  9. const publicPath = options.publicPath ? JSON.stringify(options.publicPath) : '__webpack_public_path__';
  10. const publicWorkerPath = `${publicPath} + ${JSON.stringify(file)}`;
  11. if (options.inline) {
  12. const InlineWorkerPath = JSON.stringify(`!!${_path2.default.join(__dirname, 'InlineWorker.js')}`);
  13. const fallbackWorkerPath = options.fallback === false ? 'null' : publicWorkerPath;
  14. return `require(${InlineWorkerPath})(${JSON.stringify(content)}, ${fallbackWorkerPath})`;
  15. }
  16. return `new Worker(${publicWorkerPath})`;
  17. }; /* eslint-disable multiline-ternary */
  18. exports.default = getWorker;