Range is not a constructor
Nik3181 opened this issue · 5 comments
Range is not a constructor with version 3+ in react, works fine till 2.3.0
https://codesandbox.io/s/ace-diff-react-2z19y
there is a dependency section on the bottom left corner, please try changing it to 3.0.3. including ace-builds didn't help either.
I've ran into this also using brace and webpack. The underlying cause is as follows:
i.e. Brace's Range module exports an object with a Range
value, rather than exporting a function. Brace always requires the Range module than grabs the exported Range
property e.g
https://github.com/thlorenz/brace/blob/3a00c5d59777f9d826841178e1eb36694177f5e6/mode/tcl.js#L5
Where as ace-diff attempts to use the exported value directly as a function/constructor, hence the error.
EDIT: Ace Editor itself also requires, then grabs the underlying property:
This is my first time using Ace so I can only speculate, but presumably the Range module was changed recently to export an object, not a function.
Seems as ace-diff looks first for Range
on ace
(as provided to the AceDiff
constructor), you can work around this issue with:
import ace from 'brace'
ace.Range = ace.acequire("ace/range").Range
@Benjamin-Dobell This works for me using vuejs/webpack thanks for the workaround.