@rollup/plugin-terser 0.1.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/README.md CHANGED
@@ -9,11 +9,11 @@
9
9
 
10
10
  # @rollup/plugin-terser
11
11
 
12
- 🍣 A Rollup plugin to generate a minified output bundle.
12
+ 🍣 A Rollup plugin to generate a minified bundle with terser.
13
13
 
14
14
  ## Requirements
15
15
 
16
- This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.
16
+ This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v2.0+.
17
17
 
18
18
  ## Install
19
19
 
@@ -27,7 +27,7 @@ npm install @rollup/plugin-terser --save-dev
27
27
 
28
28
  Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
29
29
 
30
- ```js
30
+ ```typescript
31
31
  import terser from '@rollup/plugin-terser';
32
32
 
33
33
  export default {
@@ -47,13 +47,34 @@ Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#comma
47
47
  The plugin accepts a terser [Options](https://github.com/terser/terser#minify-options) object as input parameter,
48
48
  to modify the default behaviour.
49
49
 
50
+ In addition to the `terser` options, it is also possible to provide the following options:
51
+
52
+ ### `maxWorkers`
53
+
54
+ Type: `Number`<br>
55
+ Default: `undefined`
56
+
57
+ Instructs the plugin to use a specific amount of cpu threads.
58
+
59
+ ```typescript
60
+ import terser from '@rollup/plugin-terser';
61
+
62
+ export default {
63
+ input: 'src/index.js',
64
+ output: {
65
+ dir: 'output',
66
+ format: 'cjs'
67
+ },
68
+ plugins: [
69
+ terser({
70
+ maxWorkers: 4
71
+ })
72
+ ]
73
+ };
74
+ ```
75
+
50
76
  ## Meta
51
77
 
52
78
  [CONTRIBUTING](/.github/CONTRIBUTING.md)
53
79
 
54
80
  [LICENSE (MIT)](/LICENSE)
55
-
56
- ## Credits
57
-
58
- This package was originally developed by [https://github.com/TrySound](TrySound) but is not
59
- maintained anymore.
package/dist/cjs/index.js CHANGED
@@ -2,9 +2,131 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var process = require('process');
6
+ var worker_threads = require('worker_threads');
7
+ var smob = require('smob');
5
8
  var terser$1 = require('terser');
9
+ var url = require('url');
10
+ var os = require('os');
11
+ var events = require('events');
12
+ var serializeJavascript = require('serialize-javascript');
6
13
 
7
- function terser(options) {
14
+ /**
15
+ * Duck typing worker context.
16
+ *
17
+ * @param input
18
+ */
19
+ function isWorkerContextSerialized(input) {
20
+ return (smob.isObject(input) &&
21
+ smob.hasOwnProperty(input, 'code') &&
22
+ typeof input.code === 'string' &&
23
+ smob.hasOwnProperty(input, 'options') &&
24
+ typeof input.options === 'string');
25
+ }
26
+ async function runWorker() {
27
+ if (worker_threads.isMainThread || !worker_threads.parentPort || !isWorkerContextSerialized(worker_threads.workerData)) {
28
+ return;
29
+ }
30
+ try {
31
+ // eslint-disable-next-line no-eval
32
+ const eval2 = eval;
33
+ const options = eval2(`(${worker_threads.workerData.options})`);
34
+ const result = await terser$1.minify(worker_threads.workerData.code, options);
35
+ const output = {
36
+ code: result.code || worker_threads.workerData.code,
37
+ nameCache: options.nameCache
38
+ };
39
+ worker_threads.parentPort.postMessage(output);
40
+ }
41
+ catch (e) {
42
+ process.exit(1);
43
+ }
44
+ }
45
+
46
+ const symbol = Symbol.for('FreeWoker');
47
+ class WorkerPool extends events.EventEmitter {
48
+ constructor(options) {
49
+ super();
50
+ this.tasks = [];
51
+ this.workers = 0;
52
+ this.maxInstances = options.maxWorkers || os.cpus().length;
53
+ this.filePath = options.filePath;
54
+ this.on(symbol, () => {
55
+ if (this.tasks.length > 0) {
56
+ this.run();
57
+ }
58
+ });
59
+ }
60
+ add(context, cb) {
61
+ this.tasks.push({
62
+ context,
63
+ cb
64
+ });
65
+ if (this.workers >= this.maxInstances) {
66
+ return;
67
+ }
68
+ this.run();
69
+ }
70
+ async addAsync(context) {
71
+ return new Promise((resolve, reject) => {
72
+ this.add(context, (err, output) => {
73
+ if (err) {
74
+ reject(err);
75
+ return;
76
+ }
77
+ if (!output) {
78
+ reject(new Error('The output is empty'));
79
+ return;
80
+ }
81
+ resolve(output);
82
+ });
83
+ });
84
+ }
85
+ run() {
86
+ if (this.tasks.length === 0) {
87
+ return;
88
+ }
89
+ const task = this.tasks.shift();
90
+ if (typeof task === 'undefined') {
91
+ return;
92
+ }
93
+ this.workers += 1;
94
+ let called = false;
95
+ const callCallback = (err, output) => {
96
+ if (called) {
97
+ return;
98
+ }
99
+ called = true;
100
+ this.workers -= 1;
101
+ task.cb(err, output);
102
+ this.emit(symbol);
103
+ };
104
+ const worker = new worker_threads.Worker(this.filePath, {
105
+ workerData: {
106
+ code: task.context.code,
107
+ options: serializeJavascript(task.context.options)
108
+ }
109
+ });
110
+ worker.on('message', (data) => {
111
+ callCallback(null, data);
112
+ });
113
+ worker.on('error', (err) => {
114
+ callCallback(err);
115
+ });
116
+ worker.on('exit', (code) => {
117
+ if (code !== 0) {
118
+ callCallback(new Error(`Minify worker stopped with exit code ${code}`));
119
+ }
120
+ });
121
+ }
122
+ }
123
+
124
+ function terser(input = {}) {
125
+ const { maxWorkers, ...options } = input;
126
+ const workerPool = new WorkerPool({
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
129
+ });
8
130
  return {
9
131
  name: 'terser',
10
132
  async renderChunk(code, chunk, outputOptions) {
@@ -17,11 +139,45 @@ function terser(options) {
17
139
  if (outputOptions.format === 'cjs') {
18
140
  defaultOptions.toplevel = true;
19
141
  }
20
- return terser$1.minify(code, { ...defaultOptions, ...(options || {}) });
142
+ try {
143
+ const { code: result, nameCache } = await workerPool.addAsync({
144
+ code,
145
+ options: smob.merge({}, options || {}, defaultOptions)
146
+ });
147
+ if (options.nameCache && nameCache) {
148
+ let vars = {
149
+ props: {}
150
+ };
151
+ if (smob.hasOwnProperty(options.nameCache, 'vars') && smob.isObject(options.nameCache.vars)) {
152
+ vars = smob.merge({}, options.nameCache.vars || {}, vars);
153
+ }
154
+ if (smob.hasOwnProperty(nameCache, 'vars') && smob.isObject(nameCache.vars)) {
155
+ vars = smob.merge({}, nameCache.vars, vars);
156
+ }
157
+ // eslint-disable-next-line no-param-reassign
158
+ options.nameCache.vars = vars;
159
+ let props = {};
160
+ if (smob.hasOwnProperty(options.nameCache, 'props') && smob.isObject(options.nameCache.props)) {
161
+ // eslint-disable-next-line prefer-destructuring
162
+ props = options.nameCache.props;
163
+ }
164
+ if (smob.hasOwnProperty(nameCache, 'props') && smob.isObject(nameCache.props)) {
165
+ props = smob.merge({}, nameCache.props, props);
166
+ }
167
+ // eslint-disable-next-line no-param-reassign
168
+ options.nameCache.props = props;
169
+ }
170
+ return result;
171
+ }
172
+ catch (e) {
173
+ return Promise.reject(e);
174
+ }
21
175
  }
22
176
  };
23
177
  }
24
178
 
179
+ runWorker();
180
+
25
181
  exports.default = terser;
26
182
  module.exports = Object.assign(exports.default, exports);
27
183
  //# sourceMappingURL=index.js.map
package/dist/es/index.js CHANGED
@@ -1,6 +1,128 @@
1
+ import process from 'process';
2
+ import { isMainThread, parentPort, workerData, Worker } from 'worker_threads';
3
+ import { isObject, hasOwnProperty, merge } from 'smob';
1
4
  import { minify } from 'terser';
5
+ import { fileURLToPath } from 'url';
6
+ import { cpus } from 'os';
7
+ import { EventEmitter } from 'events';
8
+ import serializeJavascript from 'serialize-javascript';
2
9
 
3
- function terser(options) {
10
+ /**
11
+ * Duck typing worker context.
12
+ *
13
+ * @param input
14
+ */
15
+ function isWorkerContextSerialized(input) {
16
+ return (isObject(input) &&
17
+ hasOwnProperty(input, 'code') &&
18
+ typeof input.code === 'string' &&
19
+ hasOwnProperty(input, 'options') &&
20
+ typeof input.options === 'string');
21
+ }
22
+ async function runWorker() {
23
+ if (isMainThread || !parentPort || !isWorkerContextSerialized(workerData)) {
24
+ return;
25
+ }
26
+ try {
27
+ // eslint-disable-next-line no-eval
28
+ const eval2 = eval;
29
+ const options = eval2(`(${workerData.options})`);
30
+ const result = await minify(workerData.code, options);
31
+ const output = {
32
+ code: result.code || workerData.code,
33
+ nameCache: options.nameCache
34
+ };
35
+ parentPort.postMessage(output);
36
+ }
37
+ catch (e) {
38
+ process.exit(1);
39
+ }
40
+ }
41
+
42
+ const symbol = Symbol.for('FreeWoker');
43
+ class WorkerPool extends EventEmitter {
44
+ constructor(options) {
45
+ super();
46
+ this.tasks = [];
47
+ this.workers = 0;
48
+ this.maxInstances = options.maxWorkers || cpus().length;
49
+ this.filePath = options.filePath;
50
+ this.on(symbol, () => {
51
+ if (this.tasks.length > 0) {
52
+ this.run();
53
+ }
54
+ });
55
+ }
56
+ add(context, cb) {
57
+ this.tasks.push({
58
+ context,
59
+ cb
60
+ });
61
+ if (this.workers >= this.maxInstances) {
62
+ return;
63
+ }
64
+ this.run();
65
+ }
66
+ async addAsync(context) {
67
+ return new Promise((resolve, reject) => {
68
+ this.add(context, (err, output) => {
69
+ if (err) {
70
+ reject(err);
71
+ return;
72
+ }
73
+ if (!output) {
74
+ reject(new Error('The output is empty'));
75
+ return;
76
+ }
77
+ resolve(output);
78
+ });
79
+ });
80
+ }
81
+ run() {
82
+ if (this.tasks.length === 0) {
83
+ return;
84
+ }
85
+ const task = this.tasks.shift();
86
+ if (typeof task === 'undefined') {
87
+ return;
88
+ }
89
+ this.workers += 1;
90
+ let called = false;
91
+ const callCallback = (err, output) => {
92
+ if (called) {
93
+ return;
94
+ }
95
+ called = true;
96
+ this.workers -= 1;
97
+ task.cb(err, output);
98
+ this.emit(symbol);
99
+ };
100
+ const worker = new Worker(this.filePath, {
101
+ workerData: {
102
+ code: task.context.code,
103
+ options: serializeJavascript(task.context.options)
104
+ }
105
+ });
106
+ worker.on('message', (data) => {
107
+ callCallback(null, data);
108
+ });
109
+ worker.on('error', (err) => {
110
+ callCallback(err);
111
+ });
112
+ worker.on('exit', (code) => {
113
+ if (code !== 0) {
114
+ callCallback(new Error(`Minify worker stopped with exit code ${code}`));
115
+ }
116
+ });
117
+ }
118
+ }
119
+
120
+ function terser(input = {}) {
121
+ const { maxWorkers, ...options } = input;
122
+ const workerPool = new WorkerPool({
123
+ filePath: fileURLToPath(import.meta.url),
124
+ maxWorkers
125
+ });
4
126
  return {
5
127
  name: 'terser',
6
128
  async renderChunk(code, chunk, outputOptions) {
@@ -13,10 +135,44 @@ function terser(options) {
13
135
  if (outputOptions.format === 'cjs') {
14
136
  defaultOptions.toplevel = true;
15
137
  }
16
- return minify(code, { ...defaultOptions, ...(options || {}) });
138
+ try {
139
+ const { code: result, nameCache } = await workerPool.addAsync({
140
+ code,
141
+ options: merge({}, options || {}, defaultOptions)
142
+ });
143
+ if (options.nameCache && nameCache) {
144
+ let vars = {
145
+ props: {}
146
+ };
147
+ if (hasOwnProperty(options.nameCache, 'vars') && isObject(options.nameCache.vars)) {
148
+ vars = merge({}, options.nameCache.vars || {}, vars);
149
+ }
150
+ if (hasOwnProperty(nameCache, 'vars') && isObject(nameCache.vars)) {
151
+ vars = merge({}, nameCache.vars, vars);
152
+ }
153
+ // eslint-disable-next-line no-param-reassign
154
+ options.nameCache.vars = vars;
155
+ let props = {};
156
+ if (hasOwnProperty(options.nameCache, 'props') && isObject(options.nameCache.props)) {
157
+ // eslint-disable-next-line prefer-destructuring
158
+ props = options.nameCache.props;
159
+ }
160
+ if (hasOwnProperty(nameCache, 'props') && isObject(nameCache.props)) {
161
+ props = merge({}, nameCache.props, props);
162
+ }
163
+ // eslint-disable-next-line no-param-reassign
164
+ options.nameCache.props = props;
165
+ }
166
+ return result;
167
+ }
168
+ catch (e) {
169
+ return Promise.reject(e);
170
+ }
17
171
  }
18
172
  };
19
173
  }
20
174
 
175
+ runWorker();
176
+
21
177
  export { terser as default };
22
178
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-terser",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -61,9 +61,12 @@
61
61
  }
62
62
  },
63
63
  "dependencies": {
64
+ "serialize-javascript": "^6.0.0",
65
+ "smob": "^0.0.6",
64
66
  "terser": "^5.15.1"
65
67
  },
66
68
  "devDependencies": {
69
+ "@types/serialize-javascript": "^5.0.2",
67
70
  "rollup": "^3.0.0-7",
68
71
  "typescript": "^4.8.3"
69
72
  },
package/src/index.ts CHANGED
@@ -1,24 +1,8 @@
1
- import { NormalizedOutputOptions, RenderedChunk } from 'rollup';
2
- import { minify, MinifyOptions } from 'terser';
1
+ import { runWorker } from './worker';
2
+ import terser from './module';
3
3
 
4
- export default function terser(options?: MinifyOptions) {
5
- return {
6
- name: 'terser',
4
+ runWorker();
7
5
 
8
- async renderChunk(code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions) {
9
- const defaultOptions: MinifyOptions = {
10
- sourceMap: outputOptions.sourcemap === true || typeof outputOptions.sourcemap === 'string'
11
- };
6
+ export * from './type';
12
7
 
13
- if (outputOptions.format === 'es') {
14
- defaultOptions.module = true;
15
- }
16
-
17
- if (outputOptions.format === 'cjs') {
18
- defaultOptions.toplevel = true;
19
- }
20
-
21
- return minify(code, { ...defaultOptions, ...(options || {}) });
22
- }
23
- };
24
- }
8
+ export default terser;
package/src/module.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { fileURLToPath } from 'url';
2
+
3
+ import type { NormalizedOutputOptions, RenderedChunk } from 'rollup';
4
+ import { hasOwnProperty, isObject, merge } from 'smob';
5
+
6
+ import type { Options } from './type';
7
+ import { WorkerPool } from './worker-pool';
8
+
9
+ export default function terser(input: Options = {}) {
10
+ const { maxWorkers, ...options } = input;
11
+
12
+ const workerPool = new WorkerPool({
13
+ filePath: fileURLToPath(import.meta.url),
14
+ maxWorkers
15
+ });
16
+
17
+ return {
18
+ name: 'terser',
19
+
20
+ async renderChunk(code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions) {
21
+ const defaultOptions: Options = {
22
+ sourceMap: outputOptions.sourcemap === true || typeof outputOptions.sourcemap === 'string'
23
+ };
24
+
25
+ if (outputOptions.format === 'es') {
26
+ defaultOptions.module = true;
27
+ }
28
+
29
+ if (outputOptions.format === 'cjs') {
30
+ defaultOptions.toplevel = true;
31
+ }
32
+
33
+ try {
34
+ const { code: result, nameCache } = await workerPool.addAsync({
35
+ code,
36
+ options: merge({}, options || {}, defaultOptions)
37
+ });
38
+
39
+ if (options.nameCache && nameCache) {
40
+ let vars: Record<string, any> = {
41
+ props: {}
42
+ };
43
+
44
+ if (hasOwnProperty(options.nameCache, 'vars') && isObject(options.nameCache.vars)) {
45
+ vars = merge({}, options.nameCache.vars || {}, vars);
46
+ }
47
+
48
+ if (hasOwnProperty(nameCache, 'vars') && isObject(nameCache.vars)) {
49
+ vars = merge({}, nameCache.vars, vars);
50
+ }
51
+
52
+ // eslint-disable-next-line no-param-reassign
53
+ options.nameCache.vars = vars;
54
+
55
+ let props: Record<string, any> = {};
56
+
57
+ if (hasOwnProperty(options.nameCache, 'props') && isObject(options.nameCache.props)) {
58
+ // eslint-disable-next-line prefer-destructuring
59
+ props = options.nameCache.props;
60
+ }
61
+
62
+ if (hasOwnProperty(nameCache, 'props') && isObject(nameCache.props)) {
63
+ props = merge({}, nameCache.props, props);
64
+ }
65
+
66
+ // eslint-disable-next-line no-param-reassign
67
+ options.nameCache.props = props;
68
+ }
69
+
70
+ return result;
71
+ } catch (e) {
72
+ return Promise.reject(e);
73
+ }
74
+ }
75
+ };
76
+ }
package/src/type.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { MinifyOptions } from 'terser';
2
+
3
+ export interface Options extends MinifyOptions {
4
+ nameCache?: Record<string, any>;
5
+ maxWorkers?: number;
6
+ }
7
+
8
+ export interface WorkerContext {
9
+ code: string;
10
+ options: Options;
11
+ }
12
+
13
+ export type WorkerCallback = (err: Error | null, output?: WorkerOutput) => void;
14
+
15
+ export interface WorkerContextSerialized {
16
+ code: string;
17
+ options: string;
18
+ }
19
+
20
+ export interface WorkerOutput {
21
+ code: string;
22
+ nameCache?: Options['nameCache'];
23
+ }
24
+
25
+ export interface WorkerPoolOptions {
26
+ filePath: string;
27
+ maxWorkers?: number;
28
+ }
29
+
30
+ export interface WorkerPoolTask {
31
+ context: WorkerContext;
32
+ cb: WorkerCallback;
33
+ }
@@ -0,0 +1,117 @@
1
+ import { Worker } from 'worker_threads';
2
+ import { cpus } from 'os';
3
+ import { EventEmitter } from 'events';
4
+
5
+ import serializeJavascript from 'serialize-javascript';
6
+
7
+ import type {
8
+ WorkerCallback,
9
+ WorkerContext,
10
+ WorkerOutput,
11
+ WorkerPoolOptions,
12
+ WorkerPoolTask
13
+ } from './type';
14
+
15
+ const symbol = Symbol.for('FreeWoker');
16
+
17
+ export class WorkerPool extends EventEmitter {
18
+ protected maxInstances: number;
19
+
20
+ protected filePath: string;
21
+
22
+ protected tasks: WorkerPoolTask[] = [];
23
+
24
+ protected workers = 0;
25
+
26
+ constructor(options: WorkerPoolOptions) {
27
+ super();
28
+
29
+ this.maxInstances = options.maxWorkers || cpus().length;
30
+ this.filePath = options.filePath;
31
+
32
+ this.on(symbol, () => {
33
+ if (this.tasks.length > 0) {
34
+ this.run();
35
+ }
36
+ });
37
+ }
38
+
39
+ add(context: WorkerContext, cb: WorkerCallback) {
40
+ this.tasks.push({
41
+ context,
42
+ cb
43
+ });
44
+
45
+ if (this.workers >= this.maxInstances) {
46
+ return;
47
+ }
48
+
49
+ this.run();
50
+ }
51
+
52
+ async addAsync(context: WorkerContext): Promise<WorkerOutput> {
53
+ return new Promise((resolve, reject) => {
54
+ this.add(context, (err, output) => {
55
+ if (err) {
56
+ reject(err);
57
+ return;
58
+ }
59
+
60
+ if (!output) {
61
+ reject(new Error('The output is empty'));
62
+ return;
63
+ }
64
+
65
+ resolve(output);
66
+ });
67
+ });
68
+ }
69
+
70
+ private run() {
71
+ if (this.tasks.length === 0) {
72
+ return;
73
+ }
74
+
75
+ const task = this.tasks.shift();
76
+
77
+ if (typeof task === 'undefined') {
78
+ return;
79
+ }
80
+
81
+ this.workers += 1;
82
+
83
+ let called = false;
84
+ const callCallback = (err: Error | null, output?: WorkerOutput) => {
85
+ if (called) {
86
+ return;
87
+ }
88
+ called = true;
89
+
90
+ this.workers -= 1;
91
+
92
+ task.cb(err, output);
93
+ this.emit(symbol);
94
+ };
95
+
96
+ const worker = new Worker(this.filePath, {
97
+ workerData: {
98
+ code: task.context.code,
99
+ options: serializeJavascript(task.context.options)
100
+ }
101
+ });
102
+
103
+ worker.on('message', (data) => {
104
+ callCallback(null, data);
105
+ });
106
+
107
+ worker.on('error', (err) => {
108
+ callCallback(err);
109
+ });
110
+
111
+ worker.on('exit', (code) => {
112
+ if (code !== 0) {
113
+ callCallback(new Error(`Minify worker stopped with exit code ${code}`));
114
+ }
115
+ });
116
+ }
117
+ }
package/src/worker.ts ADDED
@@ -0,0 +1,47 @@
1
+ import process from 'process';
2
+ import { isMainThread, parentPort, workerData } from 'worker_threads';
3
+
4
+ import { hasOwnProperty, isObject } from 'smob';
5
+
6
+ import { minify } from 'terser';
7
+
8
+ import type { WorkerContextSerialized, WorkerOutput } from './type';
9
+
10
+ /**
11
+ * Duck typing worker context.
12
+ *
13
+ * @param input
14
+ */
15
+ function isWorkerContextSerialized(input: unknown): input is WorkerContextSerialized {
16
+ return (
17
+ isObject(input) &&
18
+ hasOwnProperty(input, 'code') &&
19
+ typeof input.code === 'string' &&
20
+ hasOwnProperty(input, 'options') &&
21
+ typeof input.options === 'string'
22
+ );
23
+ }
24
+
25
+ export async function runWorker() {
26
+ if (isMainThread || !parentPort || !isWorkerContextSerialized(workerData)) {
27
+ return;
28
+ }
29
+
30
+ try {
31
+ // eslint-disable-next-line no-eval
32
+ const eval2 = eval;
33
+
34
+ const options = eval2(`(${workerData.options})`);
35
+
36
+ const result = await minify(workerData.code, options);
37
+
38
+ const output: WorkerOutput = {
39
+ code: result.code || workerData.code,
40
+ nameCache: options.nameCache
41
+ };
42
+
43
+ parentPort.postMessage(output);
44
+ } catch (e) {
45
+ process.exit(1);
46
+ }
47
+ }
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Plugin } from 'rollup';
2
- import { MinifyOptions } from 'terser';
1
+ import type { Plugin } from 'rollup';
2
+ import type { MinifyOptions } from 'terser';
3
3
 
4
4
  /**
5
5
  * A Rollup plugin to generate a minified output bundle.