When I originally wrote the plugin infrastructure, I had to use require.resolve to pass in the paths to the checker for the secondary processes. At the time, I was only using Coffee and ES5, so I just created a new version of the object and returned that.
When using later versions of Typescript and ES6, this is more difficult to do because of how ES6 modules work.
Description of the Change
When we load the checker via require, check to see if require.default exists. If it does, then treat it as a class that needs to be new checker.default().
Alternate Designs
Getting Typescript to generate a top-level instantiated object is difficult but not impossible. I thought it was better to allow working with the language and handling the two cases in the spell-check code instead of jumping through hoops with the plugins.
Benefits
Easier development of plugins.
Possible Drawbacks
A possibility of a class having a default property that is incorrectly tried to be called.
Applicable Issues
This is related to my work on getting additional plugins working with spell-checking.
Requirements
When I originally wrote the plugin infrastructure, I had to use
require.resolve
to pass in the paths to the checker for the secondary processes. At the time, I was only using Coffee and ES5, so I just created a new version of the object and returned that.When using later versions of Typescript and ES6, this is more difficult to do because of how ES6 modules work.
Description of the Change
When we load the checker via
require
, check to see ifrequire.default
exists. If it does, then treat it as a class that needs to benew checker.default()
.Alternate Designs
Getting Typescript to generate a top-level instantiated object is difficult but not impossible. I thought it was better to allow working with the language and handling the two cases in the
spell-check
code instead of jumping through hoops with the plugins.Benefits
Easier development of plugins.
Possible Drawbacks
A possibility of a class having a
default
property that is incorrectly tried to be called.Applicable Issues
This is related to my work on getting additional plugins working with spell-checking.