Skip to content

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

Open
@pencilcheck

Description

@pencilcheck

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

Activity

ryan-roemer

ryan-roemer commented on Oct 24, 2019

@ryan-roemer
Member

Can you give us a minimal reproduction of the issue so we can see what causes the error to evaluate how to better message it against 2.0.0+ of this plugin? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    unverifiedIssue needs verification, minimal reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @pencilcheck@ryan-roemer

      Issue actions

        Getting cryptic error if the file to return ENV object return null or {} instead · Issue #40 · FormidableLabs/babel-plugin-transform-define