unjs / unplugin

Unified plugin system for Vite, Rollup, Webpack, esbuild, Rolldown, and more
https://unplugin.unjs.io
MIT License
2.9k stars 104 forks source link

Build fail on nodejs 14. #364

Closed cweijan closed 4 months ago

cweijan commented 4 months ago

Environment

nodejs14

Reproduction

Build using nodejs14.

Describe the bug

The new code cannot be executed on nodejs14 because logical OR is used.

Additional context

No response

Logs

error during build:
/home/runner/work/vscode-office/vscode-office/packages/zip-viewer/node_modules/unplugin/dist/index.js:1021
            loader.options ||= _options;
                           ^^^

SyntaxError: Unexpected token '||='
cweijan commented 4 months ago

I solved it by upgrading the node version of CI, but errors occurred due to unplugin when the code was not changed, which was frustrating.

If it is not compatible with the old version of nodejs, the unplugin version should be upgraded to 2.x

purple-color commented 4 months ago

更新node版本到16.20.0不再报语法错误

FAOfao931013 commented 4 months ago

我更新到 16.20.2 构建成功了

kanfashidoufu commented 4 months ago

一样的问题 是因为使用了||=逻辑或赋值语法 需要Node v15.0.0以上支持 但是不向下兼容不理解 对于某些特定场景无法随意切换Node版本,切换成本较高

如果使用yarn的话 可以在package.json中添加如下配置解决

  "resolutions": {
    "unplugin": "1.7.1"
  },
raind33 commented 4 months ago

我们也是node不能轻易切换,遇到这个问题了

SuiKaSan commented 4 months ago

我们也是不能切换node版本。 直接在问题项目中安装 unplugin@1.7.1 就可以了。 它会把node_modules里的 unplugin 覆盖掉。

cweijan commented 4 months ago

我才发现这个1.8.0版本是在不到24小时前发布的, 难怪这帖这么热闹, 我刚好拿起了我很久没维护的项目🤣.

XinChou16 commented 4 months ago

这个属于破坏性变更了吧

XinChou16 commented 4 months ago

@antfu Maybe we should release a new version v1.8.1, ASAP?

sxzz commented 3 months ago

In fact, since the first version of unplugin, the minimum supported version has been node v16. However, it seems that we did not specify this in the documentation. Also considering that currently there seem to be many users of unplugin still on node 14.

Therefore, we have decided to lower the minimum supported version to v14 and will note this in the documentation. We will drop support for v14 when releasing unplugin v2 in the future.