我正在使用 rollup,并希望 babel 将单个node_modules包转译为 ES5(更准确地说:与 IE11 一起使用)。
通过以下设置,它会转译一些代码 \xe2\x80\x94 类 \xe2\x86\x92 函数,例如 \xe2\x80\x94 但它不会转译const为var\'s:
import resolve from \'@rollup/plugin-node-resolve\';\nimport commonjs from \'@rollup/plugin-commonjs\';\nimport babel from \'@rollup/plugin-babel\';\n\nexport default {\n input: \'src/index.js\',\n output: {\n file: \'dist/bundle.js\',\n format: \'umd\',\n },\n plugins: [\n resolve(),\n commonjs(),\n babel({\n babelHelpers: \'bundled\', \n exclude: \'node_modules\\/(?!(roughjs)\\/).*\', // \xe2\x86\x90 Here I try to ES5 transpile roughjs which lives in `node_modules/roughjs/bundled/rough.esm.js`\n }),\n ],\n};\nRun Code Online (Sandbox Code Playgroud)\n{\n "presets": [["@babel/env", { "modules": false }]]\n}\nRun Code Online (Sandbox Code Playgroud)\n// ...\n"browserslist": "> 0.5%, IE 11, not dead",\n// ...\nRun Code Online (Sandbox Code Playgroud)\n我的问题是:如何成功转译单个或多个node_modules包(上面给出的示例,如果有帮助)?
| 归档时间: |
|
| 查看次数: |
2042 次 |
| 最近记录: |