Fluentui: DetailsList - "Cannot redefine property" when accessing "/lib/DetailsList" because of SelectionMode being exported at multiple places

Created on 2 Jul 2019  路  10Comments  路  Source: microsoft/fluentui

Environment Information

  • __Package version(s)__: 7.6.3

Please provide a reproduction of the bug in a codepen:

It should fail display the failing message :
https://codesandbox.io/s/libdetailslist-l79rv

Actual behavior:

After upgrading to version 7, we noticed that our jest (that uses babel) tests were failing when trying to access any component from office-ui-fabric-react/lib/DetailsList by giving the message :

TypeError: Cannot redefine property: SelectionMode
        at Function.defineProperty (<anonymous>)

[...]
at node_modules/office-ui-fabric-react/lib/utilities/src/utilities/selection/index.ts:3:1
          at Array.forEach (<anonymous>)
      at Object.<anonymous> (node_modules/office-ui-fabric-react/lib/utilities/src/utilities/selection/index.ts:3:1)
      at Object.<anonymous> (node_modules/office-ui-fabric-react/lib/components/src/components/DetailsList/index.ts:1:1)
      at Object.<anonymous> (node_modules/office-ui-fabric-react/src/DetailsList.ts:1:1)
[...]

We can't directly reference from office-ui-fabric-react.

While creating the code sandbox for this issue, I noticed that the problem occurred directly so it might not be due to our jest configuration.

It's the only component that had this problem.

Expected behavior:

Should we still be able to access DetailsList through office-ui-fabric-react/lib/DetailsList?

Priorities and help requested:

Requested priority: Low

Thank you

DetailsList MarqueeSelection Fixed Type

Most helpful comment

I have recreated the codesandbox code here: https://github.com/kenotron/oufr-repro and it doesn't repro for me. Not sure what codesandbox is doing to our code here. @rhublard, can you create a repo that has this repro that isn't codesandbox (as they might be doing something odd with their bundling)

All 10 comments

Hi @rhublard, thanks for reporting this issue! I think this is happening because there are multiple places in office-ui-fabric-react that are re-exporting utilities/selection/index. I've tried this and have gotten the same error importing from:

  • office-ui-fabric-react/lib/DetailsList
  • office-ui-fabric-react/lib/MarqueeSelection
  • office-ui-fabric-react/lib/Selection

I think, in order to stop having this error, we should remove the utilities/selection/index exports from both DetailsList and MarqueeSelection.

@kenotron I'd like your input here. Does this seem correct to you?

Hi there.
Is there any updates on that? Maybe there is workaround for this issue? I have tried to export
import { ShimmeredDetailsList } from 'office-ui-fabric-react/lib/components/DetailsList/ShimmeredDetailsList'; directly but it seems that issue is still there

image

Is there a version we can expect this fix (#9750) in?

Hi @rhublard, thanks for reporting this issue! I think this is happening because there are multiple places in office-ui-fabric-react that are re-exporting utilities/selection/index. I've tried this and have gotten the same error importing from:

  • office-ui-fabric-react/lib/DetailsList
  • office-ui-fabric-react/lib/MarqueeSelection
  • office-ui-fabric-react/lib/Selection

I think, in order to stop having this error, we should remove the utilities/selection/index exports from both DetailsList and MarqueeSelection.

@kenotron Ken Chau FTE I'd like your input here. Does this seem correct to you?

We might have had to reexport because of declaration: true. So it might have been that. Not sure the next steps - will discuss offline with @jdhuntington on this.

@rhublard Sorry you're running into this! Afraid I'm having some difficulty verifying a fix, as getting a local repro is proving non-trivial. Somehow the codesandbox link seems to work fine when cloning and running locally.

Is it possible to clone the repo that is encountering this build issue? If not, are you willing to share a few more details such as...

  • jest version
  • jest config
  • babel version
  • babel config

thank you!

I have recreated the codesandbox code here: https://github.com/kenotron/oufr-repro and it doesn't repro for me. Not sure what codesandbox is doing to our code here. @rhublard, can you create a repo that has this repro that isn't codesandbox (as they might be doing something odd with their bundling)

@sushruth: @jdhuntington has prepared a PR that reverts one of the most recent instances of an additional export of SelectionMode. This PR has just been merged. The bot will notify in about 6 hours time when there is a version of OUFR you can consume the fix in.

version 7.19.1 contains the fix, and the codesandbox you provided appears to work correctly when targeting that version.

@rhublard @yury-stepanov @sushruth Please let us know if this fixes the issues you've been having.

Hi, it solved our issue, we were able to run jest.

Thank you for the fix!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quanglefed picture quanglefed  路  33Comments

just-joshing picture just-joshing  路  35Comments

ryancole picture ryancole  路  39Comments

danmarshall picture danmarshall  路  37Comments

chrismohr picture chrismohr  路  45Comments