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

refactor: check all falsy conditions of plugins and opts before returning NoWorkResult in process() #1908

Merged
merged 1 commit into from Jan 4, 2024

Conversation

ahmdammarr
Copy link
Contributor

resolves #1869

Fixes:

  • refactor check of all falsy condition of plugins and opts before returing NoWorkResult in Processor.process().

postcss/lib/processor.js

Lines 44 to 55 in a0a82d3

process(css, opts = {}) {
if (
this.plugins.length === 0 &&
typeof opts.parser === 'undefined' &&
typeof opts.stringifier === 'undefined' &&
typeof opts.syntax === 'undefined'
) {
return new NoWorkResult(this, css, opts)
} else {
return new LazyResult(this, css, opts)
}
}

For a full repro see : https://github.com/romainmenke/postcss-no-work-result-sourcemaps

By setting parser: null as a processing option you can force a LazyResult.

Setting null instead of undefined is a common mistake, especially when not using TypeScript.

Is it intentional that NoWorkResult and LazyResult have different CSS outputs?

@ai
Copy link
Member

ai commented Dec 29, 2023

It looks good to me. It is too late for release for me, I will try to release it tomorrow.

@ahmdammarr ahmdammarr changed the title refactor: check all falsy conditions of plugins and opts before returning NoWorkResult instance in process() refactor: check all falsy conditions of plugins and opts before returning NoWorkResult in process() Dec 29, 2023
@ai ai merged commit f2e7a9f into postcss:main Jan 4, 2024
8 checks passed
@ai
Copy link
Member

ai commented Jan 4, 2024

Thanks. Released in 8.4.33.

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

Successfully merging this pull request may close these issues.

NoWorkResult and LazyResult have very subtle differences and these can be accidentally encountered
2 participants