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
{{ message }}
Repository navigation
Using require.main.require instead of require for dialects #7354
good first issueFor issues. An issue that is a good choice for first-time contributors.staletype: featureDEPRECATED: replace with the "feature" issue type
I wanted to suggest that when sequelize is loading in dialect modules that instead of using require() like normally, you use require.main.require(). Or at least provide the option to do so.
The difference between the two is that normal require() always point to the module that is calling the require method. However require.main.require() uses the scope of the topmost module in the hierarchy which is usually the module that is being run by the user.
My use case is that I have created a small framework for my employer which is using sequelize. When using this framework in a project it is installed using npm and then required by the project. However the framework needs to include all the possible dialects in it's project.json which makes the install take significantly longer which hurts our build process and increases the size on disk.
However if sequelize was using require.main.require() wouldn't have to install all the dialects in the framework but could instead install only the dialects I need directly in the project.
This should not break anything that is using sequelize directly as require.main always points at the top level module.
I hope what I said made sense and I apologize for any grammar errors.
good first issueFor issues. An issue that is a good choice for first-time contributors.staletype: featureDEPRECATED: replace with the "feature" issue type
Activity
janmeier commentedon Mar 14, 2017
I've never had this issue myself, but it should be fine to go so - PR welcome!
BTW, why do you have to include all dialects? We use sequelize with postgres, and only have pg in our package
grimurd commentedon Mar 14, 2017
@janmeier Because it's a framework, and not all the projects using the framework are using the same database :)
I'll try to make a PR in the next few days.