Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Babel targets configuration for browser and node builds

Aberta
#982 4 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
30/100
Tipo de issue
Documentação
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
babel, javascript, rollup
Domínio
build-system, tooling

Direção de pesquisa

Start by reading the undocumented --target CLI flag and the package.json exports question, then reproduce the browser and Node builds with the shown Babel targets. Done means documenting supported configuration guidance for separate outputs and their exports; the issue names no source file or test.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

For a while I have been using the following babel preset for production bundles:

        ...
        "presets": [
          [
            "@babel/preset-env",
            {
              "targets": [
                "defaults",
                "maintained node versions"
              ]
            }
          ]
        ],
        ...

This configuration seems to be incompatible with microbundle as it generates errors such as unknown Statement of type "ForOfStatement" when the source contains for (... of ...) statements. Using "presets": ["@babel/preset-env"] without specifying targets works. However, I am concerned about the compatibility achieved by such "default" builds.

What is the proper way to use microbundle to build for both the browser and for node? What's the correct babel configuration to use? I am fine with having one build for the browser and another for Node, but how should one define package.json exports in that case?

I do realize microbundle probably does the correct thing by default, but I am a bit skeptical given the existence of the --target CLI flag, for which little documentation exists.

Linguagem predominante
JavaScript
Estrelas
8.1k
Forks
358
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de developit/microbundle

Todas as issues de developit/microbundle

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.