I want to transpile the contents of my src
directory as well as some packages in node_modules with the help of babel . I'm using the following command as my npm script in package.json:
"build": "babel ./packages/myproject/src --include packages/myproject/node_modules/abc-,packages/leaf-sitemap/node_modules/qwe- --out-dir ./packages/myproject/dist"
in order to include all packages which start with abc-
or qwe-
The output error I get is:
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 compiles the contents of my src
folder successfully however it doesn't transpile the contents of node_module packages which start with abc-
or qwe-
.
What I tried:
- using regex after the include statement.
adding include in babel.config.js at root level like so:
include: [ /node_modules/(abc-|qwe-)/ ]
The babel packages I'm using: "@babel/cli": "^7.5.5", "@babel/core": "^7.5.5"
but all plugin proposals are of version 7.0.0.
Not sure if this is relevant but the packages which start with abc-
or qwe-
are symlinks. Not sure if this complicates my problem.
None of these attempts didn't help. What am I doing wrong?
UPDATE: I tried a few more attempts with globbing as per @Powell Ye
comment. I restricted myself to just abc-
type packages. It seems that -
is a special character in globbing patterns so removing it made progress:
"build": "babel ./packages/myproject/src --include packages/myproject/node_modules/abc* --out-dir ./packages/myproject/dist"
However I still got Octal literal in strict mode
BABEL_PARSE_ERROR parsing error.