-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] dev mode babel run use includeRegExp and excludeRegExp
- Loading branch information
Showing
5 changed files
with
53 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as Path from "path"; | ||
|
||
/** | ||
* Get a babel exclude function to filter out files that should not | ||
* transpile. | ||
* | ||
* @param xarcOptions - xarc dev options | ||
* @returns babel exclude function | ||
*/ | ||
export const getBabelExclude = (xarcOptions: any) => { | ||
const AppMode = xarcOptions.AppMode; | ||
|
||
const clientVendor = Path.join(AppMode.src.client, "vendor/"); | ||
const { includeRegExp, excludeRegExp } = xarcOptions.babel; | ||
|
||
const babelExclude = (x: string) => { | ||
if (includeRegExp && includeRegExp.find((r: RegExp) => x.match(r))) { | ||
return false; | ||
} | ||
|
||
if (excludeRegExp && excludeRegExp.find((r: RegExp) => x.match(r))) { | ||
return true; | ||
} | ||
|
||
if (x.indexOf("node_modules") >= 0) { | ||
if (x.indexOf("~es2x~") >= 0 || x.indexOf("~es6~") >= 0) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
if (x.indexOf(clientVendor) >= 0) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
return babelExclude; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters