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

Allow plugins to be added without modifying global package state #713

Closed
not-an-aardvark opened this issue Aug 2, 2018 · 3 comments
Closed

Comments

@not-an-aardvark
Copy link
Contributor

not-an-aardvark commented Aug 2, 2018

We're encountering an issue in ESLint where acorn throws an error when two different versions of espree are loaded at the same time.

The tl;dr of the issue is that espree works by adds a plugin to acorn (i.e. setting acorn.plugins.espree), and exposing an interface that invokes acorn with the espree plugin enabled. If there are multiple versions of espree that depend on the same version of acorn, they can inadvertently override each others' plugins since they're both setting acorns.plugins.espree. The result is that invoking one version of espree might end up calling the parser methods of a different version of espree, which causes a crash because the second version of espree wasn't expecting its parser methods to be called.

In other words, the root cause of the issue is that it's not currently possible to use a plugin without modifying shared global state.


What would you think about adding a function that returns a "fresh" copy of the acorn library, which would be guaranteed to not have been touched by any other package consumers? Bluebird has something like this with Promise.getNewLibraryCopy.

Another possible way to resolve the issue would be to update the plugin interface so that it returns a wrapper module that auto-applies the given plugins (along the lines of request.defaults), but this seems like it could cause compatibility issues.

@marijnh
Copy link
Member

marijnh commented Sep 11, 2018

This should be fixed in version 6.0 (to be released this week), via patch 7a20d80 . The downside, of course, is that plugins will have to be upgraded before you'll be able to use them with 6.0. If you need help porting a given plugin for which I haven't already submitted a pull request, let me know.

@marijnh
Copy link
Member

marijnh commented Sep 14, 2018

This has been implemented in version 6.

@marijnh marijnh closed this as completed Sep 14, 2018
@not-an-aardvark
Copy link
Contributor Author

Great, thanks!

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

No branches or pull requests

2 participants