Update CLI to pass options to presets & plugins

オープン
#302 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript
領域
cli

調査の方向性

Start at the CLI's transform-option normalization, focusing on the proposed normalizeTransformOpts and normalizePluginPresets behavior. Decide which preset-option syntax to support, then verify that options such as modules: commonjs reach @babel/preset-env and that the shown CLI invocation works.

索引モデルが issue の本文から書いたものです。

説明

With Babel 8, the default value of modules in @bablel/preset-env is no longer commonjs but ESM. This is not supported in base Browserify, as far as I know, necessitating passing an explicit modules option to present-env. This is not yet possible as far as I can tell in the CLI but in my fork I added:

function normalizeTransformOpts(opts) {
  // ...

  if (Array.isArray(opts.plugins)) opts.plugins = normalizePluginPresets(opts.plugins)
  if (Array.isArray(opts.presets)) opts.presets = normalizePluginPresets(opts.presets)

  // ...
}

function normalizePluginPresets(opts) {
  opts = opts.slice()

  for (let i = 0; i < opts.length; i++) {
    if (opts[i]._) {
      opts[i] = [
        opts[i]._[0],
        Object.assign({}, opts[i])
      ]

      delete opts[i][1]._
    }
  }

  return opts
}

The following CLI does then work:

-t [ babelify --presets [ [ @babel/preset-env --modules commonjs ] @babel/preset-react ]

I can start a PR if that is the preferred syntax. Alternatively:

-t [ babelify --presets [ [ @babel/preset-env [ --modules commonjs ] ] @babel/preset-react ]
主要言語
JavaScript
スター
1.7k
フォーク
112
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

babel/babelify のほかの issue

babel/babelify の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。