botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Question] ES6 default import of builder not working in 3.8.4

Open tomoakley opened this issue 9 years ago • 9 comments

System Information (Required)

  • SDK Language: Node
  • SDK Version: 3.8.4
  • Development Environment: Digital Ocean droplet, Ubuntu 16.04

Issue Description

I'm using an ES6 import to require the builder and some botbuilder imports, like this:

import builder, {Middleware, UniversalBot, IntentDialog, EntityRecognizer} from 'botbuilder'

This worked perfectly in 3.5.4, however since upgrading to 3.8.4, I get error messages saying TypeError: Cannot read property 'CardAction' of undefined (using like builder.CardAction). If I do console.log(builder) it comes out as undefined. All of the other non-default imports work perfectly. A short-term fix for this issue is to put any builder.Object item in the import, but I don't this is think sustainable going forward.

Code Example

import builder from 'botbuilder'

const connector = new builder.ChatConnector({ appId: process.env.MICROSOFT_BOT_FRAMEWORK_ID, appPassword: process.env.MICROSOFT_BOT_FRAMEWORK_SECRET })

Cannot read property ChatConnector of undefined.

Expected Behavior

Default import of builder should be a defined object, which it was in 3.5.4 but appears to have broken in 3.8.4

Actual Results

  1. Cannot read property Object of undefined
  2. console.log(builder) // undefined

tomoakley avatar Jun 18 '17 23:06 tomoakley

same problem here, seems to have stopped working. needed to roll back to 3.7.0

macrozone avatar Jun 19 '17 09:06 macrozone

Confirmed, 3.7.0 works as expected, thanks @macrozone.

tomoakley avatar Jun 19 '17 14:06 tomoakley

Use const builder = require('botbuilder'); instead of import.

nwhitmont avatar Jun 19 '17 14:06 nwhitmont

Contributions welcome! Feel free to submit a pull request which includes the desired functionality.

nwhitmont avatar Jun 19 '17 15:06 nwhitmont

@nwhitmont excuse me, but this is a regression. Is there a changelog that describes this breaking change? Please reopen this issue.

macrozone avatar Jun 20 '17 06:06 macrozone

@nwhitmont still happens with 3.9.1. It's a undocumented breaking change.

using 'import' instead of 'require' should also be pretty standard these days.

macrozone avatar Sep 13 '17 12:09 macrozone

@macrozone @tomoakley use import * as builder from 'botbuilder'

ThejanW avatar Oct 03 '17 02:10 ThejanW

Any suggestion? Because it doesn't work for me in either 3.7.0 or 3.8.4 version.

sahar922 avatar Feb 11 '18 10:02 sahar922

import * as builder from 'botbuilder' this thing works but can anybody explain why import builder from 'botbuilder' is not working (I am using 3.14.1)? Acc to me, it should have worked as expected.

InsaneNaman avatar Apr 13 '18 16:04 InsaneNaman