From d7cdd0c8dd6e85e13688c9e88e0e1a440623759a Mon Sep 17 00:00:00 2001 From: Nick Rabinowitz Date: Tue, 27 Oct 2020 06:59:09 -0700 Subject: [PATCH 1/3] Support extensions in babel build --- modules/dev-tools/scripts/build.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/dev-tools/scripts/build.sh b/modules/dev-tools/scripts/build.sh index 9990bc74..320e532b 100755 --- a/modules/dev-tools/scripts/build.sh +++ b/modules/dev-tools/scripts/build.sh @@ -5,6 +5,7 @@ set -e DEV_TOOLS_DIR=`node -e "require('ocular-dev-tools/node/module-dir')()"` CONFIG=`node $DEV_TOOLS_DIR/node/get-config.js ".babel.configPath"` MODULES=`node $DEV_TOOLS_DIR/node/get-config.js ".modules" | sed -E "s/,/ /g"` +EXTENSIONS=".js" check_target() { if [[ ! "$1" =~ ^es5|es6|esm ]]; then @@ -13,6 +14,13 @@ check_target() { fi } +build_src() { + OUT_DIR=$1 + TARGET=$2 + check_target $TARGET + BABEL_ENV=$TARGET npx babel src --config-file $CONFIG --out-dir $OUT_DIR --copy-files --source-maps --extensions $EXTENSIONS +} + build_module() { if [ -z "$1" ]; then TARGETS="es6 esm es5" @@ -21,12 +29,10 @@ build_module() { fi N=`echo "$TARGETS" | wc -w` if [ $N -eq 1 ]; then - check_target $TARGETS - BABEL_ENV=$TARGETS npx babel src --config-file $CONFIG --out-dir dist --copy-files --source-maps + build_src dist $TARGETS else for T in ${TARGETS}; do( - check_target $T - BABEL_ENV=$T npx babel src --config-file $CONFIG --out-dir dist/$T --copy-files --source-maps + build_src dist/$T $T ); done fi } @@ -42,6 +48,9 @@ build_monorepo() { --dist) TARGET=$2 shift ;; + --extensions) + EXTENSIONS=$2 + shift ;; *) echo -e "\033[91mUnknown option $1. ocular-build [--dist es5|es6|esm,...] [module1,...]\033[0m" exit 1 ;; From a23bc286a1541cd618928b612f6681a77d79cf5f Mon Sep 17 00:00:00 2001 From: Nick Rabinowitz Date: Tue, 27 Oct 2020 07:12:50 -0700 Subject: [PATCH 2/3] Set default to babel CLI default --- modules/dev-tools/scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dev-tools/scripts/build.sh b/modules/dev-tools/scripts/build.sh index 320e532b..4932a5f8 100755 --- a/modules/dev-tools/scripts/build.sh +++ b/modules/dev-tools/scripts/build.sh @@ -5,7 +5,7 @@ set -e DEV_TOOLS_DIR=`node -e "require('ocular-dev-tools/node/module-dir')()"` CONFIG=`node $DEV_TOOLS_DIR/node/get-config.js ".babel.configPath"` MODULES=`node $DEV_TOOLS_DIR/node/get-config.js ".modules" | sed -E "s/,/ /g"` -EXTENSIONS=".js" +EXTENSIONS=".es6,.js,.es,.jsx,.mjs" check_target() { if [[ ! "$1" =~ ^es5|es6|esm ]]; then From 2dddf00a311b55b9edf74ad0a0e6bd4f71720de4 Mon Sep 17 00:00:00 2001 From: Nick Rabinowitz Date: Tue, 27 Oct 2020 08:50:32 -0700 Subject: [PATCH 3/3] Move extensions to ocular-dev-tools.config, add to README --- docs/dev-tools/README.md | 2 ++ modules/dev-tools/config/ocular.config.js | 3 ++- modules/dev-tools/scripts/build.sh | 5 +---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/dev-tools/README.md b/docs/dev-tools/README.md index 43f42aa0..ef6e8669 100644 --- a/docs/dev-tools/README.md +++ b/docs/dev-tools/README.md @@ -87,6 +87,8 @@ A file `ocular-dev-tools.config.js` can be placed at the root of the package to - `lint` + `paths` (Arrray) - directories to include when linting. Default `['modules', 'src']` + `extensions` (Array) - file extensions to include when linting. Default `['js', 'md']` +- `babel` + + `extensions` - List of file extensions (prefixed with `.`) that `babel` will process. Default `['.es6', '.js', '.es', '.jsx', '.mjs']` - `aliases` (Object) - additional [module aliases](https://www.npmjs.com/package/module-alias) to use in tests. Default {}. - `entry` (Object) - entry points for tests. + `test` (String) - unit test entry point. Default `./test/index`. diff --git a/modules/dev-tools/config/ocular.config.js b/modules/dev-tools/config/ocular.config.js index e3b300fc..dd9201fa 100644 --- a/modules/dev-tools/config/ocular.config.js +++ b/modules/dev-tools/config/ocular.config.js @@ -32,7 +32,8 @@ module.exports = (opts = {}) => { resolve(packageRoot, './babel.config.js'), resolve(packageRoot, './.babelrc'), resolve(__dirname, './babel.config.js') - ]) + ]), + extensions: ['.es6', '.js', '.es', '.jsx', '.mjs'] }, lint: { diff --git a/modules/dev-tools/scripts/build.sh b/modules/dev-tools/scripts/build.sh index 4932a5f8..4bd29dab 100755 --- a/modules/dev-tools/scripts/build.sh +++ b/modules/dev-tools/scripts/build.sh @@ -5,7 +5,7 @@ set -e DEV_TOOLS_DIR=`node -e "require('ocular-dev-tools/node/module-dir')()"` CONFIG=`node $DEV_TOOLS_DIR/node/get-config.js ".babel.configPath"` MODULES=`node $DEV_TOOLS_DIR/node/get-config.js ".modules" | sed -E "s/,/ /g"` -EXTENSIONS=".es6,.js,.es,.jsx,.mjs" +EXTENSIONS=`node $DEV_TOOLS_DIR/node/get-config.js ".babel.extensions"` check_target() { if [[ ! "$1" =~ ^es5|es6|esm ]]; then @@ -48,9 +48,6 @@ build_monorepo() { --dist) TARGET=$2 shift ;; - --extensions) - EXTENSIONS=$2 - shift ;; *) echo -e "\033[91mUnknown option $1. ocular-build [--dist es5|es6|esm,...] [module1,...]\033[0m" exit 1 ;;