Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins need access to rollup version and/or to plugin API version #1374

Closed
ezolenko opened this issue Apr 20, 2017 · 4 comments · Fixed by #2394
Closed

Plugins need access to rollup version and/or to plugin API version #1374

ezolenko opened this issue Apr 20, 2017 · 4 comments · Fixed by #2394

Comments

@ezolenko
Copy link

Some plugin API changes break plugins when lower than expected rollup version is used.

For example warn()/error() on context given to transform() and any new entry point ever added.

A sane way of retrieving rollup version would help a lot. Having a plugin API version would be ideal.

@olsonpm
Copy link
Contributor

olsonpm commented May 16, 2017

isn't this what peerDependencies are for?

@ezolenko
Copy link
Author

ezolenko commented May 16, 2017

peerDependencies solve part of the problem (the biggest part) -- of requiring minimum or a range of versions. But it doesn't help with providing different functionality within that range. For example I had to do this to avoid keeling over on older rollup version:

// this.context is set from transform's this
this.hasContext = _.isFunction(this.context.warn) && _.isFunction(this.context.error);

if (this.hasContext)
{
	if (this.bail)
		this.context.error(`${this.prefix}${message}`);
	else
		this.context.warn(`${this.prefix}${message}`);
}
else
	console.log(`${this.prefix}${message}`);

This works and is sufficient for this specific case. But there is no way to test for which plugin entry points would be called (I think intro/outro were introduced fairly recently for example).

(I don't have an actual problem that would be solved btw, this is more of a nice to have for the future)

@Rich-Harris
Copy link
Contributor

This makes sense. Do you have a particular way of doing this in mind? One way you could presumably do it without any changes to Rollup is this:

const resolved = require.resolve('rollup');
const { version } = require(`${resolved}/package.json`);

@ezolenko
Copy link
Author

ezolenko commented Jun 5, 2017

Maybe rollup can add plugin API version (and own version) to config object it passes to options() call?

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

Successfully merging a pull request may close this issue.

4 participants