Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Breaks with multiple outputs #5

Closed
NaridaL opened this issue Sep 16, 2018 · 20 comments
Closed

Breaks with multiple outputs #5

NaridaL opened this issue Sep 16, 2018 · 20 comments

Comments

@NaridaL
Copy link

NaridaL commented Sep 16, 2018

rollup.config.js

import { terser } from 'rollup-plugin-terser'

export default {
	input: "index.js",
	output: [
		{
			format: "umd",
			file: "index.umd.min.js",
			name: "index",
		},
		{
			format: "es",
			file: "index.module.min.js",
		},
	],
	plugins: [
		terser(),
	],
}

index.js

export const FOO = 2

versions

{
    "rollup": "^0.66.0",
    "rollup-plugin-terser": "^3.0.0",
    "terser": "^3.8.2"
}
PS C:\Users\aval\tsdev\rpterser> npm run rollup

> rpterser@1.0.0 rollup C:\Users\aval\tsdev\rpterser
> rollup -c
Output
index.js → index.umd.min.js, index.module.min.js...
[!] (terser plugin) Error: Farm is ended, no more calls can be done to it
Error: Farm is ended, no more calls can be done to it
    at exports.default.end (C:\Users\aval\tsdev\rpterser\node_modules\jest-worker\build\index.js:166:13)
    at Object.generateBundle (C:\Users\aval\tsdev\rpterser\node_modules\rollup-plugin-terser\index.js:38:19)
    at C:\Users\aval\tsdev\rpterser\node_modules\rollup\dist\rollup.js:20850:25
    at process._tickCallback (internal/process/next_tick.js:68:7)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rpterser@1.0.0 rollup: `rollup -c`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rpterser@1.0.0 rollup script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\aval\AppData\Roaming\npm-cache\_logs\2018-09-16T16_09_11_939Z-debug.log

Expected output: should work

Commenting out either output config prevents errors.

@TrySound
Copy link
Owner

Could you try to use multiple configs instead of multiple outputs? Like this

import { terser } from 'rollup-plugin-terser'

export default [
  {
    input: "index.js",
    output: {
      format: "umd",
      file: "index.umd.min.js",
      name: "index",
    },
    plugins: [ terser() ],
  },
  {
    input: "index.js",
    output: {
      format: "es",
      file: "index.module.min.js",
    },
    plugins: [ terser() ],
  }
]

@NaridaL
Copy link
Author

NaridaL commented Sep 16, 2018

Sure, that works, but the original config should too.

@TrySound
Copy link
Owner

Yes, sure. Just temporary workaround. Thinking on solving this issue.

jayands added a commit to node-ebml/node-ebml that referenced this issue Sep 17, 2018
[rpt]: TrySound/rollup-plugin-terser#5

Due to a bug in [`rollup-plugin-terser`][rpt], the version is now locked
at v2.0.2 until that's resolved.  I checked the other deps, though, and
there's no reason they can't update to their latest versions.  This
should simultaneously satisfy dependabot's recommendations.

Signed-off-by: Jonathan Sifuentes <jayands.dev@gmail.com>
@jhoffmcd
Copy link

Confirmed, the issue is surfacing for me with a multiple output config as well.

austinleroy pushed a commit to austinleroy/node-ebml that referenced this issue Sep 22, 2018
[rpt]: TrySound/rollup-plugin-terser#5

Due to a bug in [`rollup-plugin-terser`][rpt], the version is now locked
at v2.0.2 until that's resolved.  I checked the other deps, though, and
there's no reason they can't update to their latest versions.  This
should simultaneously satisfy dependabot's recommendations.

Signed-off-by: Jonathan Sifuentes <jayands.dev@gmail.com>
@motss
Copy link

motss commented Sep 29, 2018

Facing the same issue after new release of Rollup

@Ziv-Barber
Copy link

Same here.

@berkaytheunicorn
Copy link

same here too.

@visormatt
Copy link

Also rolling back / downgrading to 2.0.2 works will work with the array of outputs as a short term solution.

@TrySound
Copy link
Owner

@visormatt Multiple configs instead of multiple outputs also work.

@visormatt
Copy link

@visormatt Multiple configs instead of multiple outputs also work.

Thanks for the suggestion @TrySound. Unfortunately we're using it in a monorepo which would be a bit more work to update and we'd prefer to hold off until its supported as its simply IMO a cleaner approach

@janriemer
Copy link

I've made a PR that should fix this. 😉

@lucifer1004
Copy link

Mark here to get notifications when this issue is fixed.

@kopax
Copy link

kopax commented Dec 16, 2018

Any update on this? I have the same error

@TrySound
Copy link
Owner

@kopax I'm gonna merge #19 soon. Currently I recommend to use multiconfig or v1 instead.

@kopax
Copy link

kopax commented Dec 16, 2018

@TrySound thanks for your explanation.

Do you mean v1 of terser plugin ?

I've fixed by using multiconfig:

// this was commented
// if (prod) plugins.push(uglify(), visualizer({ filename: './bundle-stats.html' }));
// if (prod) plugins.push(terser(), visualizer({ filename: './bundle-stats.html' }));

export default [{
  input: 'src/index.js',
  external,
  output: output.filter((o) => o.format !== 'es'),
// does not work ?
//  plugins: prod ? plugins.concat([uglify(), visualizer({ filename: './bundle-stats.html' })]) : plugins,
  plugins,
}, {
  input: 'src/index.js',
  external,
  output: output.filter((o) => o.format === 'es'),
  plugins: prod ? plugins.concat([terser(), visualizer({ filename: './bundle-stats.html' })]) : plugins,
}];

I am able to build but as you can see, I have lost the uglify step except for the es module.

I have tried to used both plugin uglify and terser, this give me the error:

src/index.js → dist/@bootstrap-styled/color.min.js, dist/@bootstrap-styled/color.cjs.min.js...
[!] (uglify plugin) Error: Farm is ended, no more calls can be done to it
Error: Farm is ended, no more calls can be done to it
    at exports.default.end (/home/dka/workspace/github.com/bootstrap-styled/color/node_modules/rollup-plugin-uglify/node_modules/jest-worker/build/index.js:166:13)
    at Object.generateBundle (/home/dka/workspace/github.com/bootstrap-styled/color/node_modules/rollup-plugin-uglify/index.js:38:19)
    at /home/dka/workspace/github.com/bootstrap-styled/color/node_modules/rollup/dist/rollup.js:21948:25
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

Do you also have a solution for that ?

@kopax
Copy link

kopax commented Dec 16, 2018

Nevermind, I have found that uglify plugin also need to be called once per instance.

export default output.map((output) => {
  return {
    input: 'src/index.js',
    external,
    output,
    plugins: prod ? plugins.concat([terser(), visualizer({ filename: './bundle-stats.html' })]) : plugins,
  }
});

@ericxyly
Copy link

I have the same error 😢

TrySound pushed a commit to evs-chris/rollup-plugin-terser that referenced this issue Jan 1, 2019
This fixes an error that occurs when multiple outputs are specified
for bundling.
Reason:
- jest-worker was not cleaned up properly

Fixes TrySound#5
TrySound pushed a commit to evs-chris/rollup-plugin-terser that referenced this issue Jan 1, 2019
@kopax
Copy link

kopax commented Jan 2, 2019

Is this fixed?

@TrySound
Copy link
Owner

TrySound commented Jan 2, 2019

@kopax Yep. Should be fixed in v4

@visormatt
Copy link

No changes were required in our configuration other than bumping the version. Great work and thanks for the wonderful package @TrySound and contributors 🙇

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.