You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package currently works by performing side effects. That definitely discourages its usage. I'm going to look for alternatives now, but I would have definitely used this package if there was a way to require/import it without modifying other stuff.
There's no need to break any existing code. My suggestion is to have a types/ folder, with each separate type as a file, that doesn't modify anything, but rather just exports the type, so you can import all of them through const geoJsonTypes = require('mongoose-geojson-schema/types'), or only Point through const Point = require('mongoose-geojson-schema/types/Point').
The way I would more commonly use it is const { Point, Polygon } = require('mongoose-geojson-schema/types');
I would be happy to write up a PR for this, I just want to make sure it wouldn't get rejected because of philosophical reasons
The text was updated successfully, but these errors were encountered:
I strongly agree with this, although it would be a breaking change. Right now simply loading the module modifies the global mongoose instance.
These days a lot of editor have integration to identify unused imports-- a useful feature!
But today it's harder to figure out if this module is actually being used because it does this "action-at-a-distance" thing of modifying the mongoose global during import. It would be a lot clearer what it was doing if only exported the types would could then be used.
This package currently works by performing side effects. That definitely discourages its usage. I'm going to look for alternatives now, but I would have definitely used this package if there was a way to require/import it without modifying other stuff.
There's no need to break any existing code. My suggestion is to have a
types/
folder, with each separate type as a file, that doesn't modify anything, but rather just exports the type, so you can import all of them throughconst geoJsonTypes = require('mongoose-geojson-schema/types')
, or onlyPoint
throughconst Point = require('mongoose-geojson-schema/types/Point')
.The way I would more commonly use it is
const { Point, Polygon } = require('mongoose-geojson-schema/types');
I would be happy to write up a PR for this, I just want to make sure it wouldn't get rejected because of philosophical reasons
The text was updated successfully, but these errors were encountered: