Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pure export #28

Open
towc opened this issue Jun 21, 2018 · 1 comment
Open

add pure export #28

towc opened this issue Jun 21, 2018 · 1 comment

Comments

@towc
Copy link

towc commented Jun 21, 2018

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

@markstos
Copy link
Contributor

markstos commented Oct 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants