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

refactor: use global.$MongooseDriver to store current driver to remove webpack warnings #6771

Merged
merged 4 commits into from
Jul 28, 2018

Conversation

vkarpov15
Copy link
Collaborator

@vkarpov15 vkarpov15 commented Jul 25, 2018

This refactor is just a bit too meaty for me to merge into master directly, I'd like to review it a couple more times.

The problem with #6705 is that we use global.MONGOOSE_DRIVER_PATH all over the place in require() statements to support the existing custom driver paradigm, which is what makes the browser library possible. This PR changes it so that we look at global.MONGOOSE_DRIVER_PATH once when mongoose is first require()-ed in node and store it in a global.$MongooseDriver variable. The lib/browser.js entry point won't look at global.MONGOOSE_DRIVER_PATH at all.

The hard part is that this added the potential for messy cycling dependencies, because require('./driver') -> require('./collection') -> require('./utils') -> require('./types/Decimal128') -> require('./driver') and the alternative is to use global.$MongooseDriver in transactional code, which sounds gross.

@vkarpov15
Copy link
Collaborator Author

My mistake, this PR is supposed to reference #6705

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

Successfully merging this pull request may close these issues.

1 participant