Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Babel watch is broken for multiple subdirectories on 7.17.X #14269

Closed
1 task
faow opened this issue Feb 14, 2022 · 4 comments 路 Fixed by #14281
Closed
1 task

[Bug]: Babel watch is broken for multiple subdirectories on 7.17.X #14269

faow opened this issue Feb 14, 2022 · 4 comments 路 Fixed by #14281
Assignees
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: cli

Comments

@faow
Copy link

faow commented Feb 14, 2022

馃捇

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

https://github.com/faow/babel_test

Configuration file name

No response

Configuration

{
    "ignore": [
        "**/*.d.ts",
        "**/node_modules/**"
    ],
    "presets": [
        "@babel/preset-typescript"
    ]
}

Current and expected behavior

Current Behaviour:

If you add --watch to the compiler and have multiple subdirectories, the watcher compiles every edited file to the input and output directory.

It seems like multiple watchers are spawned. For every subdirectory the same file gets compiled again.

Babel without watch

 > npx babel "*/src" --out-dir ../webapp --source-maps true --extensions ".ts" --copy-files --include-dotfiles --relative --verbose

subFolder1\src\test1.ts -> subFolder1\webapp\test1.js
subFolder2\src\test2.ts -> subFolder2\webapp\test2.js
Successfully compiled 2 files with Babel (444ms).

Babel with watch initial compilation (working)

 > npx babel "*/src" --out-dir ../webapp --source-maps true --extensions ".ts" --copy-files --include-dotfiles --relative --watch --verbose

subFolder1\src\test1.ts -> subFolder1\webapp\test1.js
subFolder2\src\test2.ts -> subFolder2\webapp\test2.js
Successfully compiled 2 files with Babel (576ms).

Babel with watch: compilation after editing a file (not working)

subFolder1\src\test1.ts -> subFolder1\webapp\test1.js
subFolder1\src\test1.ts -> subFolder1\src\test1.js

The second compilation should not happen.

Babel with watch and 3 subfolders: Initial and editing a file

For this case simple add another subfolder to the github sample project.

> npx babel "*/src" --out-dir ../webapp --source-maps true --extensions ".ts" --copy-files --include-dotfiles --relative --watch --verbose

subFolder1\src\test1.ts -> subFolder1\webapp\test1.js
subFolder2\src\test2.ts -> subFolder2\webapp\test2.js
subFolder3\src\test3.ts -> subFolder3\webapp\test3.js
Successfully compiled 3 files with Babel (420ms).
subFolder3\src\test3.ts -> subFolder3\src\test3.js
subFolder3\src\test3.ts -> subFolder3\src\test3.js
subFolder3\src\test3.ts -> subFolder3\webapp\test3.js

The first and second compilation should not happen.

Expected behaviour:
With

  • "@babel/cli": "7.16.8"
  • "@babel/core": "7.16.12"

it is working as expected. Just install the mentioned versions to the github sample project.

> npx babel "*/src" --out-dir ../webapp --source-maps true --extensions ".ts" --copy-files --include-dotfiles --relative --watch --verbose

subFolder1\src\test1.ts -> subFolder1\webapp\test1.js
subFolder2\src\test2.ts -> subFolder2\webapp\test2.js
subFolder3\src\test3.ts -> subFolder3\webapp\test3.js
Successfully compiled 3 files with Babel (423ms).
subFolder2\src\test2.ts -> subFolder2\webapp\test2.js
Successfully compiled 1 file with Babel (109ms).

Environment

System:

  • OS: Windows 10 10.0.19043

Binaries:

  • Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
  • npm: 8.3.2 - C:\Program Files\nodejs\npm.CMD

npmPackages:

  • @babel/cli: 7.17.0 => 7.17.0
  • @babel/core: 7.17.2 => 7.17.2
  • @babel/preset-typescript: 7.16.7 => 7.16.7

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @faow! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@faow faow changed the title [Bug]: [Bug]: Babel watch is broken for multiple subdirectories on 7.17.X Feb 14, 2022
@JLHwung JLHwung self-assigned this Feb 15, 2022
@JLHwung
Copy link
Contributor

JLHwung commented Feb 16, 2022

This is a regression introduced in #14065, where we merged multiple separate watcher into one (to share the external deps map) but the merged watcher has registered multiple listeners.

@nicolo-ribaudo
Copy link
Member

Fixes in v7.17.6

@faow
Copy link
Author

faow commented Feb 28, 2022

Working on our side. Thank you!

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 31, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: cli
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants