@rollup/plugin-terser 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -6,6 +6,7 @@ var process = require('process');
6
6
  var worker_threads = require('worker_threads');
7
7
  var smob = require('smob');
8
8
  var terser$1 = require('terser');
9
+ var url = require('url');
9
10
  var os = require('os');
10
11
  var events = require('events');
11
12
  var serializeJavascript = require('serialize-javascript');
@@ -120,10 +121,11 @@ class WorkerPool extends events.EventEmitter {
120
121
  }
121
122
  }
122
123
 
123
- function terser(options = {}) {
124
+ function terser(input = {}) {
125
+ const { maxWorkers, ...options } = input;
124
126
  const workerPool = new WorkerPool({
125
- filePath: __filename,
126
- maxWorkers: options.maxWorkers
127
+ filePath: url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href))),
128
+ maxWorkers
127
129
  });
128
130
  return {
129
131
  name: 'terser',
package/dist/es/index.js CHANGED
@@ -2,6 +2,7 @@ import process from 'process';
2
2
  import { isMainThread, parentPort, workerData, Worker } from 'worker_threads';
3
3
  import { isObject, hasOwnProperty, merge } from 'smob';
4
4
  import { minify } from 'terser';
5
+ import { fileURLToPath } from 'url';
5
6
  import { cpus } from 'os';
6
7
  import { EventEmitter } from 'events';
7
8
  import serializeJavascript from 'serialize-javascript';
@@ -116,10 +117,11 @@ class WorkerPool extends EventEmitter {
116
117
  }
117
118
  }
118
119
 
119
- function terser(options = {}) {
120
+ function terser(input = {}) {
121
+ const { maxWorkers, ...options } = input;
120
122
  const workerPool = new WorkerPool({
121
- filePath: __filename,
122
- maxWorkers: options.maxWorkers
123
+ filePath: fileURLToPath(import.meta.url),
124
+ maxWorkers
123
125
  });
124
126
  return {
125
127
  name: 'terser',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-terser",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/module.ts CHANGED
@@ -1,13 +1,17 @@
1
+ import { fileURLToPath } from 'url';
2
+
1
3
  import type { NormalizedOutputOptions, RenderedChunk } from 'rollup';
2
4
  import { hasOwnProperty, isObject, merge } from 'smob';
3
5
 
4
6
  import type { Options } from './type';
5
7
  import { WorkerPool } from './worker-pool';
6
8
 
7
- export default function terser(options: Options = {}) {
9
+ export default function terser(input: Options = {}) {
10
+ const { maxWorkers, ...options } = input;
11
+
8
12
  const workerPool = new WorkerPool({
9
- filePath: __filename,
10
- maxWorkers: options.maxWorkers
13
+ filePath: fileURLToPath(import.meta.url),
14
+ maxWorkers
11
15
  });
12
16
 
13
17
  return {