FormidableLabs / FormidableLabs/babel-plugin-transform-define

Getting cryptic error if the file to return ENV object return null or {} instead

オープン
#40 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
unverified
主要言語
JavaScript
スター
242
フォーク
29
PR マージ指標
30日以内にマージされた PR はありません

説明

I have solved the issue myself but I thought it can be better.

It is good that it throws an error about it but the cryptic error message like this is not helping
```
remote: Module build failed: TypeError: /tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/components/BuildTeam.js: Cannot convert undefined or null to object
remote: at PluginPass.UnaryExpression (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-plugin-transform-define/lib/index.js:34:27)
remote: at newFn (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/visitors.js:276:21)
remote: at NodePath._call (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/path/context.js:76:18)
remote: at NodePath.call (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/path/context.js:48:17)
remote: at NodePath.visit (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/path/context.js:105:12)
remote: at TraversalContext.visitQueue (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/context.js:150:16)
remote: at TraversalContext.visitSingle (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/context.js:108:19)
remote: at TraversalContext.visit (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/context.js:192:19)
remote: at Function.traverse.node (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/index.js:114:17)
remote: at NodePath.visit (/tmp/build_43fb00b7ca544651b6eb4730c0d0ad94/node_modules/babel-traverse/lib/path/context.js:115:19)
```
This throws when the page it is saying at fault does not even use any of the variables supposed to be defined in env, but simply uses Unary Expression like "typeof".

Perhaps make the error clearer if the env passed in .babelrc is returning {} or null?

Thanks

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

.babelrc の ENV 設定と babel-plugin-transform-define/lib/index.js の失敗するパスを確認することから始めます。ENV が null または {} を返すケースを、typeof のような単項式だけを使用するファイルも含めて再現します; TypeError の不可解な内容を露出させるのではなく、ENV の値が無効であると失敗が報告すれば完了です。

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

評価

技術スタック
javascript
領域
build-system, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

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

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