2

我想src在 babel 的帮助下转换我的目录的内容以及 node_modules 中的一些包。我在 package.json 中使用以下命令作为我的 npm 脚本:

"build": "babel ./packages/myproject/src --include packages/myproject/node_modules/abc-,packages/leaf-sitemap/node_modules/qwe- --out-dir ./packages/myproject/dist"

为了包括所有以abc-或开头的包qwe-

我得到的输出错误是:

Successfully compiled 14 files with Babel.
/Users/me/code/packages/abc-schemas/src/index.js:1
(function (exports, require, module, __filename, __dirname) { import mongoose from 'mongoose'

Babel 成功编译了我的文件夹的内容,但是它不会转换以orsrc开头的 node_module 包的内容。abc-qwe-

我尝试了什么:

  1. 在 include 语句后使用正则表达式。
  2. 在根级别添加包含在 babel.config.js 中,如下所示:

    包括:[ /node_modules/(abc-|qwe-)/ ]

我正在使用的 babel 包: "@babel/cli": "^7.5.5", "@babel/core": "^7.5.5"

但所有插件提案都是 7.0.0 版本。

不确定这是否相关,但以符号链接开头的abc-软件包qwe-。不确定这是否会使我的问题复杂化。

这些尝试都没有帮助。我究竟做错了什么?

更新:根据评论,我尝试了更多尝试使用 globbing @Powell Ye。我限制自己只abc-输入包。这似乎-是 globbing 模式中的一个特殊字符,因此删除它取得了进展:

"build": "babel ./packages/myproject/src --include packages/myproject/node_modules/abc* --out-dir ./packages/myproject/dist"

但是我仍然遇到Octal literal in strict modeBABEL_PARSE_ERROR 解析错误。

4

0 回答 0