Skip to content

copy-files flag does not respect ignore block in .babelrc #6226

@mattgoucher

Description

@mattgoucher

Bug: If in your build script, you have --copy-files passed, files that are ignored in .babelrc files will be copied over, instead of being ignored.

Input Code

babel src --out-dir lib --copy-files

Babel Configuration (.babelrc, package.json, cli command)

{
  "presets": [
    "es2015",
    "stage-1",
    "react"
  ],
  "ignore": [
    "**__mocks__/*.js"
  ]
}

Expected Behavior

Babel should not copy files that are explicitly ignored in .babelrc configuration. In this case, babel should not transpile or copy Jest mocks.

Current Behavior

Babel copies files that are ignored are explicitly .babelrc.

> npm run build 
> babel src --out-dir lib --copy-files
  src/api/__mocks__/index.js -> lib/api/__mocks__/index.js
  src/api/endpoints.js -> lib/api/endpoints.js

If you pass an --ignore flag (with the same blob) after the --copy-files flag, it will behave as expected.

> npm run build;
> babel src --out-dir lib --copy-files --ignore **__mocks__/*.js
  src/api/endpoints.js -> lib/api/endpoints.js
  (output does not include ignored directories)

Context

This issue comes up when you work with Jest manual mocks inside of your source directory. Jest warns that you have duplicate mocks directories.

software version(s)
Babel 6.26.0
node 6.9.2
npm 5.4.0
Operating System OSX El Capitan

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: cli

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions