From d32a5ae6385840a115d4e18bf443b5c1d7b8ec4b Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Wed, 27 Nov 2019 01:26:00 -0500 Subject: [PATCH 1/2] fix docs: `ignore` and `only` take arrays as arguments - just passing a single regex causes errors: - Error: .ignore must be an array, or undefined - Error: .only must be an array, or undefined --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 440d6d6..ad080fa 100644 --- a/README.md +++ b/README.md @@ -129,11 +129,11 @@ $ browserify -t [ babelify --sourceMapsAbsolute ] browserify().transform(babelify.configure({ // Optional ignore regex - if any filenames **do** match this regex then // they aren't compiled - ignore: /regex/, + ignore: [/regex/], // Optional only regex - if any filenames **don't** match this regex // then they aren't compiled - only: /my_es6_folder/ + only: [/my_es6_folder/] })) ``` @@ -192,7 +192,7 @@ Another solution (proceed with caution!) is to run babelify as a [global](https: ```js browserify().transform("babelify", { global: true, - ignore: /\/node_modules\/(?!app\/)/ + ignore: [/\/node_modules\/(?!app\/)/] }); ``` From a2527e0273a8022a5e05a46a7cbdf8b3c9cdd649 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Wed, 27 Nov 2019 02:05:13 -0500 Subject: [PATCH 2/2] test: ensure `ignore` and `only` options pass - to ensure the docs I just fixed have a passing usage test somewhere --- test/options.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/options.js b/test/options.js index b5e1a4b..3ed6662 100644 --- a/test/options.js +++ b/test/options.js @@ -10,7 +10,9 @@ test('passes options via configure', function(t) { b.transform(babelify.configure({ presets: ['@babel/preset-env'], - plugins: ['@babel/plugin-transform-property-literals'] + plugins: ['@babel/plugin-transform-property-literals'], + ignore: [/fakeregex/], + only: [/index.js$/, /a.js$/, /b.js$/, /c.js$/] })); b.bundle(function (err, src) { @@ -27,7 +29,9 @@ test('passes options via browserify', function(t) { b.transform(babelify, { presets: ['@babel/preset-env'], - plugins: ['@babel/plugin-transform-property-literals'] + plugins: ['@babel/plugin-transform-property-literals'], + ignore: [/fakeregex/], + only: [/index.js$/, /a.js$/, /b.js$/, /c.js$/] }); b.bundle(function (err, src) {