securingsincity / react-ace

React Ace Component
http://securingsincity.github.io/react-ace/
MIT License
4.07k stars 605 forks source link

Forces importing ace-builds, CDN not respected #1377

Open hyperknot opened 2 years ago

hyperknot commented 2 years ago

Problem

I'm trying to exclude ace-build from a webpack bundle and load it via CDN. My problem is that react-ace always imports it, even if getAceInstance() correctly detects that we are under the CDN scenario.

The core of the problem seems to be this usage of Range here. https://github.com/securingsincity/react-ace/blob/7709bf27699b33bdba91b46a2a6b1aacc5f1aa64/src/ace.tsx#L1 and here: https://github.com/securingsincity/react-ace/blob/7709bf27699b33bdba91b46a2a6b1aacc5f1aa64/src/ace.tsx#L538

I believe this should be changed to ace.Range.

Also, changing all the imports to import type would highlight this problems and make sure that ace-builds is not included accidentally. For example:

import type { Ace } from 'ace-builds'
import type * as AceBuilds from 'ace-builds'

Sample code to reproduce your issue

Just import the library in create-react-app.

References

Progress on: #

ErikBrendel commented 6 months ago

Hey have you found a solution yet for using react-ace with a CDN-provided ace build? I also just stumbled across this, might bring massive build time and size optimizations