unjs/std-env

Version 3.4.0 Incompatible with Node.js 12

godky opened this issue · 5 comments

godky commented

Environment

std-env: v3.4.0
Node.js: v12.22.2

Reproduction

It looks like the 3.4.0 build doesn't work properly on Node.js v12 anymore, which uses ?? and ?. and other ES2020 syntax. But 3.3.3 doesn't have this problem. Wouldn't it be more appropriate as a BREAKING CHANGE?

Describe the bug

Throw error when run in Node.js v12. SyntaxError: Unexpected token '.'

Additional context

No response

Logs

No response

pi0 commented

Hi. Thanks for opening the issue and sorry for trouble this release caused you.

Node.js 12 support is long overdue (more than a year ago). Dropping support for not supported Node.js versions is typically not a breaking change unless they are widely used so i recommend you to upgrade to a supported Node.js version of pin std-env (using overrides or resolutions field in package.json to ^3.3 if cannot upgrade at the moment.

image
godky commented

Well, I think that although node v12 is not being maintained, there may actually be quite a few projects still in use for various reasons. As a widely used dependency package, it is better to be more cautious when doing major syntax upgrades, especially in minor version iteration.

pi0 commented

Yes, this is why we haven't used optional chaining syntax in lower-level packages such as std-env for this long. May I ask which platform are you using that has Node 12 yet?

godky commented

yeah,It is true that most platforms no longer support node12, but they all do so during major version upgrades. Just like eslint-plugin-vue, every time an old version of node is dropped, a major version is released. Because the syntax in std-env@3.3.3 is compatible to node8 or even lower, but this is no longer the case in 3.4. I encountered this problem because webpackbar was used in the project, and webpackbar depends on std-env@^3.3.3. I suddenly encountered the issue today. After investigation, I found that 3.4.0 had a syntax upgrade.I sincerely recommend revisiting this issue.

pi0 commented