Skip to content
Permalink
Browse files
Emit deprecation warning when requiring non-cordova modules
  • Loading branch information
raphinesse committed Sep 28, 2018
1 parent 1fdc38d commit 27a2cfd6c53cc268ae7200b877216aa146243a3f
Showing 1 changed file with 8 additions and 0 deletions.
@@ -54,6 +54,14 @@ var compatMap = {
Context.prototype.requireCordovaModule = function (modulePath) {
const [pkg, ...pkgPath] = modulePath.split('/');

if (!pkg.match(/^cordova-[^/]+/)) {
events.emit('warn',
`Using "requireCordovaModule" to load non-cordova module ` +
`"${modulePath}" is deprecated. Instead, add this module to ` +
`your dependencies and use regular "require" to load it.`
);
}

if (pkg !== 'cordova-lib') return require(modulePath);

// There is a very common mistake, when hook requires some cordova functionality

0 comments on commit 27a2cfd

Please sign in to comment.