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

Multiple versions of this library can't coexist #143

Closed
Antonio-Laguna opened this issue Nov 19, 2021 · 2 comments
Closed

Multiple versions of this library can't coexist #143

Antonio-Laguna opened this issue Nov 19, 2021 · 2 comments

Comments

@Antonio-Laguna
Copy link
Contributor

  • Operating System (or Browser): macOS
  • Node Version: 14.17.6
  • postcss-values-parser Version: 6.0.1

How Do We Reproduce?

After this bug surfaced csstools/postcss-preset-env#225 we started to investigate what could be causing it given that it works locally but fails within postcss-preset-env@7.0.0

We've realised that registerWalker is modifying the prototype of Container which means that if you have multiple versions of this package running you're in for a bad time.

The registering happens here:

Container.prototype[walkerName] = function walker(callback) {
which runs multiple times (once per version) while
if ((isTypeCallable && node instanceof type) || (!isTypeCallable && node.type === type)) {
makes it so node is only an instance of type for the first postcss-values-parser that does it's registering which makes this non-deterministic and kind-of dangerous if multiple instances coexist.

Expected Behavior

Should be possible to have different versions without them interfering.

Actual Behavior

It's not possible to do that.

I understand that this is not a trivial change and I'm happy to contribute time and/or to discuss anything.

@shellscape
Copy link
Owner

I'd be happy to review a PR to resolve this. The package has been up and relatively stable for a number of years, so I don't have a lot of personal motivation to dive into this one.

@shellscape
Copy link
Owner

This is resolved in the major/css-tree branch, which will be released as v7

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

No branches or pull requests

2 participants