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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[es-dev-server] Default babel configuration breaks custom one #1295

Closed
Lodin opened this issue Feb 1, 2020 · 3 comments · Fixed by #1242
Closed

[es-dev-server] Default babel configuration breaks custom one #1295

Lodin opened this issue Feb 1, 2020 · 3 comments · Fixed by #1242
Labels
bug Something isn't working

Comments

@Lodin
Copy link
Contributor

Lodin commented Feb 1, 2020

I'm using es-dev-server through the karma-esm, lerna, and united custom karma configuration for each package of multirepository. To start karma in a separate package, I need to import babel.config.json in the karma configuration file and load it through the babelConfig of karma-esm.

However, when I do it, karma fails with the following error:

Error compiling: Duplicate plugin/preset detected.

My babel.config.json file is the following:

{
  "comments": false,
  "presets": ["@babel/preset-typescript"],
  "plugins": [
    [
      "@babel/plugin-proposal-nullish-coalescing-operator",
      {
        "loose": true
      }
    ],
    ["@babel/plugin-proposal-optional-chaining", {"loose": true}]
  ]
}

I just require it as a JSON file and push it to babelConfig option.

After some research, I found that es-dev-server loads some default configuration that includes @babel/plugin-proposal-nullish-coalescing-operator, @babel/plugin-proposal-optional-chaining, etc. That configuration merges with my configuration and due to name differences has the duplicates inside. It happens here.

I think there should be some checks that disables default configuration if the user configuration is used or a some kind of option to disable default configuration.

@Lodin
Copy link
Contributor Author

Lodin commented Feb 1, 2020

UPDATE: Issue happens only with @babel/plugin-proposal-nullish-coalescing-operator, @babel/plugin-proposal-optional-chaining on board. There is a remark that these plugins could be removed when babel/babel#10811 is merged. It is merged 21 days ago, the latest babel release was 7.8.5, so I think it can be removed now. I can create a PR for it if you don't mind.

However, still something should be done for deduping plugins or at least the list of used plugins should be mentioned in the documentation somewhere.

@LarsDenBakker
Copy link
Member

There is a PR for removing those plugins #1242

I'm surprised this causes babel conflicts, I wasn't aware of that. That makes it pretty hard to compose plugins. Will look into it

@LarsDenBakker LarsDenBakker added the bug Something isn't working label Feb 1, 2020
@Lodin
Copy link
Contributor Author

Lodin commented Feb 1, 2020

BTW, the workaround for this issue is quite simple. You just need to make sure your plugins that conflict with the default ones are moved to a separate environment and not affect the test one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants