diff --git a/web/module_paths.json b/web/module_paths.json
new file mode 100644
index 00000000..9ff4337f
--- /dev/null
+++ b/web/module_paths.json
@@ -0,0 +1,107 @@
+{
+  "externals": [
+    "pgadmin.user_management.current_user",
+    "translations",
+    "pgadmin.browser.endpoints",
+    "pgadmin.browser.messages",
+    "pgadmin.browser.utils",
+    "pgadmin.server.supported_servers"
+  ],
+  "paths": {
+    "pgadmin.misc.explain": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/misc/static/explain/js/explain",
+    "pgadmin.node.constraints": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/static/js/constraints",
+    "pgadmin.node.resource_group": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/resource_groups/static/js/resource_group",
+    "pgadmin.node.edbvar": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/static/js/edbvar",
+    "pgadmin.node.fts_parser": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/static/js/fts_parser",
+    "slick.pgadmin.editors": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/../static/js/slickgrid/slick.pgadmin.editors",
+    "pgadmin.browser.node": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/node",
+    "pgadmin.server.supported_servers": "/browser/server/supported_servers",
+    "pgadmin.node.synonym": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym",
+    "pgadmin.node.user_mapping": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/static/js/user_mapping",
+    "pgadmin.node.exclusion_constraint": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint",
+    "pgadmin.node.pga_job": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job",
+    "pgadmin.datagrid": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/datagrid/static/js/datagrid",
+    "pgadmin.tools.debugger.direct": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/debugger/static/js/direct",
+    "pgadmin.browser.bgprocess": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/misc/bgprocess/static/js/bgprocess",
+    "pgadmin.node.index": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index",
+    "pgadmin.node.foreign_key": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key",
+    "pgadmin.file_manager": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/misc/file_manager/static/js/file_manager",
+    "pgadmin.node.foreign_data_wrapper": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper",
+    "pgadmin.node.domain": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain",
+    "pgadmin.node.foreign_server": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/static/js/foreign_server",
+    "pgadmin.preferences": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/preferences/static/js/preferences",
+    "pgadmin.tools.backup": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/backup/static/js/backup",
+    "pgadmin.node.server": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/static/js/server",
+    "pgadmin.browser.object_sql": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/misc/sql/static/js/sql",
+    "pgadmin.browser.node.ui": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/node.ui",
+    "pgadmin.node.function": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function",
+    "pgadmin.node.mview": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview",
+    "pgadmin.tools.import_export": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/import_export/static/js/import_export",
+    "pgadmin.node.partition": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition",
+    "pgadmin.browser.datamodel": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/datamodel",
+    "pgadmin.file_utility": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/misc/file_manager/static/js/utility",
+    "pgadmin.node.schema": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema",
+    "pgadmin.browser.table.partition.utils": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils",
+    "pgadmin.node.tablespace": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace",
+    "pgadmin.node.procedure": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure",
+    "pgadmin.node.catalog_object_column": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/static/js/catalog_object_column",
+    "pgadmin.node.trigger_function": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function",
+    "pgadmin.node.trigger": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger",
+    "pgadmin.browser.endpoints": "/browser/js/endpoints",
+    "pgadmin.node.role": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/roles/static/js/role",
+    "pgadmin.browser.object_statistics": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/misc/statistics/static/js/statistics",
+    "pgadmin.browser.server.variable": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/static/js/variable",
+    "pgadmin.dashboard": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/dashboard/static/js/dashboard",
+    "pgadmin.tools.restore": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/restore/static/js/restore",
+    "pgadmin.node.table": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table",
+    "pgadmin.browser": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/browser",
+    "pgadmin.node.foreign_table": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table",
+    "pgadmin.node.pga_schedule": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule",
+    "pgadmin.sqleditor": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/sqleditor/static/js/sqleditor",
+    "pgadmin.browser.server.privilege": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/static/js/privilege",
+    "pgadmin.browser.utils": "/browser/js/utils",
+    "pgadmin.node.type": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type",
+    "pgadmin.node.server_group": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/static/js/server_group",
+    "pgadmin.node.database": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/static/js/database",
+    "pgadmin.tools.maintenance": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/maintenance/static/js/maintenance",
+    "pgadmin.tools.debugger.controller": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/debugger/static/js/debugger",
+    "pgadmin.browser.panel": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/panel",
+    "translations": "/tools/translations",
+    "pgadmin.node.package": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package",
+    "pgadmin.settings": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/settings/static/js/settings",
+    "pgadmin.node.pga_jobstep": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep",
+    "pgadmin.node.catalog_object": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object",
+    "pgadmin.browser.object_depends": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/misc/depends/static/js/depends",
+    "pgadmin.node.cast": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast",
+    "pgadmin.node.collation": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation",
+    "pgadmin.node.primary_key": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key",
+    "pgadmin.node.language": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language",
+    "pgadmin.tools.debugger.ui": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/debugger/static/js/debugger_ui",
+    "pgadmin.browser.messages": "/browser/js/messages",
+    "pgadmin.about": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/about/static/js/about",
+    "pgadmin.node.rule": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule",
+    "pgadmin.tools.user_management": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/user_management/static/js/user_management",
+    "pgadmin.browser.error": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/error",
+    "pgadmin.node.domain_constraints": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints",
+    "pgadmin.node.column": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column",
+    "pgadmin.node.sequence": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence",
+    "pgadmin.user_management.current_user": "/user_management/current_user",
+    "pgadmin.node.check_constraint": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint",
+    "pgadmin.node.fts_template": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template",
+    "pgadmin.node.catalog": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog",
+    "pgadmin.node.event_trigger": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger",
+    "pgadmin.browser.menu": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/menu",
+    "pgadmin.node.edbproc": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/static/js/edbproc",
+    "slick.pgadmin.formatters": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/../static/js/slickgrid/slick.pgadmin.formatters",
+    "pgadmin.browser.collection": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/collection",
+    "pgadmin.node.fts_dictionary": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary",
+    "pgadmin.node.edbfunc": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/static/js/edbfunc",
+    "pgadmin.browser.wizard": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/wizard",
+    "pgadmin.node.unique_constraint": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint",
+    "pgadmin.tools.grant_wizard": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/tools/grant_wizard/static/js/grant_wizard",
+    "pgadmin.browser.frame": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/static/js/frame",
+    "pgadmin.node.fts_configuration": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration",
+    "pgadmin.node.view": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view",
+    "pgadmin.node.extension": "/Users/surinder/Documents/Projects/pgadmin4_fresh/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension"
+  }
+}
\ No newline at end of file
diff --git a/web/pgAdmin4.py b/web/pgAdmin4.py
index 4a185570..f98dac33 100644
--- a/web/pgAdmin4.py
+++ b/web/pgAdmin4.py
@@ -47,24 +47,38 @@ if not os.path.isfile(config.SQLITE_PATH):
 # Server startup
 ##########################################################################
 
-# Build Javascript files
-if config.DEBUG:
-    javascriptBundler = JavascriptBundler()
-    javascriptBundler.bundle()
-
 # Create the app!
 app = create_app()
 
+@app.route('/paths/list')
+def list_module_paths():
+    from flask import current_app
+    from pgadmin.utils.ajax import make_json_response
+
+    return make_json_response(data=current_app.javascripts)
+
+# Build Javascript files
 if config.DEBUG:
-    app.debug = True
-else:
-    app.debug = False
+    # With help of App's test_client, call to route internally is possible
+    # and current_app is accessible after app is created and thus list of
+    # module JS are retrieved which is helpful in building paths for webpack.
+    with app.test_client() as client:
+        import simplejson as json
+        list_scripts = client.get('/paths/list')
+        scripts = json.loads(list_scripts.data)
+
+    javascriptBundler = JavascriptBundler()
+    javascriptBundler.bundle(scripts['data'])
+
+app.debug = True if config.DEBUG else False
 
 # respond to JS
 if config.DEBUG:
     if javascriptBundler.report() == JsState.NONE:
         app.logger.error("Unable to generate javascript")
-        app.logger.error("To run the app ensure that yarn install command runs successfully")
+        app.logger.error(
+            "To run the app ensure that yarn install command runs successfully"
+        )
         raise Exception("No generated javascript, aborting")
 
 # Start the web server. The port number should have already been set by the
diff --git a/web/pgadmin/utils/javascript/javascript_bundler.py b/web/pgadmin/utils/javascript/javascript_bundler.py
index 6016adb0..3dcf169c 100644
--- a/web/pgadmin/utils/javascript/javascript_bundler.py
+++ b/web/pgadmin/utils/javascript/javascript_bundler.py
@@ -8,6 +8,7 @@
 ##########################################################################
 
 import os
+from flask import current_app
 from contextlib import contextmanager
 from subprocess import call
 from pgadmin.utils import u, fs_encoding, file_quote
@@ -26,8 +27,10 @@ class JavascriptBundler:
     def __init__(self):
         self.jsState = JsState.NONE
 
-    def bundle(self):
+    def bundle(self, scripts=None):
         try:
+            # Save JS module path references into path.json
+            write_paths(scripts)
             try_building_js()
             self.jsState = JsState.NEW
         except OSError:
@@ -42,6 +45,31 @@ class JavascriptBundler:
         return self.jsState
 
 
+def build_paths(scripts):
+    js_files = {}
+    js_files['paths'] = {}
+    js_files['externals'] = []
+    for script in scripts:
+        js_files['paths'][script['name']] = script['path']
+        if 'is_template' in script and script['is_template']:
+            js_files['externals'].append(script['name'])
+    return js_files
+
+
+def write_paths(scripts):
+    js_files = build_paths(scripts)
+    data = {
+        'externals': js_files['externals'],
+        'paths': js_files['paths']
+    }
+    try:
+        import simplejson as json
+        with open(webdir_path() + '/module_paths.json', 'w') as outfile:
+            json.dump(data, outfile, indent=2)
+    except Exception as e:
+        current_app.logger.exception(e)
+
+
 @contextmanager
 def pushd(new_dir):
     previous_dir = os.getcwd()
diff --git a/web/webpack.config.js b/web/webpack.config.js
index 5919a0ad..232bed41 100644
--- a/web/webpack.config.js
+++ b/web/webpack.config.js
@@ -100,9 +100,9 @@ module.exports = {
   entry: {
     'app.bundle': sourceDir + '/bundle/app.js',
     codemirror: sourceDir + '/bundle/codemirror.js',
-    sqleditor: './pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js',
-    debugger_direct: './pgadmin/tools/debugger/templates/debugger/js/direct.js',
-    file_utils: './pgadmin/misc/file_manager/templates/file_manager/js/utility.js',
+    sqleditor: './pgadmin/tools/sqleditor/static/js/sqleditor.js',
+    debugger_direct: './pgadmin/tools/debugger/static/js/direct.js',
+    file_utils: './pgadmin/misc/file_manager/static/js/utility.js',
     pgadmin_css: './pgadmin/static/scss/pgadmin.scss',
     style_css: './pgadmin/static/css/style.css',
   },
@@ -117,15 +117,7 @@ module.exports = {
   // Templates files which contains python code needs to load dynamically
   // Such files specified in externals are loaded at first and defined in
   // the start of generated bundle within define(['libname'],fn) etc.
-  externals: {
-    'pgadmin.browser.messages': 'pgadmin.browser.messages',
-    'pgadmin.browser.utils': 'pgadmin.browser.utils',
-    'pgadmin.browser.endpoints': 'pgadmin.browser.endpoints',
-    'pgadmin.server.supported_servers': 'pgadmin.server.supported_servers',
-    'pgadmin.user_management.current_user': 'pgadmin.user_management.current_user',
-    'pgadmin.node.unique_key': 'pgadmin.node.unique_key',
-    'translations': 'translations',
-  },
+  externals: webpackShimConfig.externals,
   module: {
     // References:
     // Module and Rules: https://webpack.js.org/configuration/module/
@@ -155,15 +147,15 @@ module.exports = {
       query: webpackShimConfig,
       include: path.join(__dirname, '/pgadmin/browser'),
     }, {
-      test: require.resolve('./pgadmin/tools/datagrid/templates/datagrid/js/datagrid'),
+      test: require.resolve('./pgadmin/tools/datagrid/static/js/datagrid'),
       use: {
         loader: 'imports-loader?' +
         'pgadmin.dashboard' +
         ',pgadmin.tools.user_management' +
-        ',misc.statistics' +
-        ',misc.depends' +
-        ',misc.sql' +
-        ',misc.bgprocess' +
+        ',pgadmin.browser.object_statistics' +
+        ',pgadmin.browser.object_depends' +
+        ',pgadmin.browser.object_sql' +
+        ',pgadmin.browser.bgprocess' +
         ',pgadmin.node.server_group' +
         ',pgadmin.node.server' +
         ',pgadmin.node.database' +
@@ -221,15 +213,15 @@ module.exports = {
         loader: 'imports-loader?' +
         'pgadmin.about' +
         ',pgadmin.preferences' +
-        ',misc.file_manager' +
+        ',pgadmin.file_manager' +
         ',pgadmin.settings' +
-        ',tools.backup' +
-        ',tools.restore' +
-        ',tools.grant_wizard' +
-        ',tools.maintenance' +
-        ',tools.import_export' +
-        ',tools.debugger' +
-        ',tools.direct',
+        ',pgadmin.tools.backup' +
+        ',pgadmin.tools.restore' +
+        ',pgadmin.tools.grant_wizard' +
+        ',pgadmin.tools.maintenance' +
+        ',pgadmin.tools.import_export' +
+        ',pgadmin.tools.debugger.controller' +
+        ',pgadmin.tools.debugger.direct',
       },
     }, {
       test: require.resolve('snapsvg'),
diff --git a/web/webpack.shim.js b/web/webpack.shim.js
index d3d560bd..c8e730a5 100644
--- a/web/webpack.shim.js
+++ b/web/webpack.shim.js
@@ -1,6 +1,56 @@
 /* eslint-env node */
 //Configuration file contains requireJS like shim and paths used by webpack shim-loader
 const path = require('path');
+const config = require('./module_paths.json');
+
+let vendorPaths = {
+  'bundled_codemirror': path.join(__dirname, './pgadmin/static/bundle/codemirror'),
+  'bundled_browser': path.join(__dirname, './pgadmin/static/bundle/browser'),
+  'sources': path.join(__dirname, './pgadmin/static/js'),
+  'pgadmin': path.join(__dirname, './pgadmin/static/js/pgadmin'),
+  'tools.translations': path.join(__dirname, './pgadmin/tools/templates/js/translations'),
+  'sources/gettext': path.join(__dirname, './pgadmin/static/js/gettext'),
+  'babel-polyfill': path.join(__dirname, './node_modules/babel-polyfill/dist/polyfill'),
+
+  // Vendor JS
+  'jquery': path.join(__dirname, './node_modules/jquery/dist/jquery'),
+  'wcdocker': path.join(__dirname, './node_modules/webcabin-docker/Build/wcDocker'),
+  'alertify': path.join(__dirname, './node_modules/alertifyjs/build/alertify'),
+  'moment': path.join(__dirname, './node_modules/moment/moment'),
+  'jquery.event.drag': path.join(__dirname, './node_modules/slickgrid/lib/jquery.event.drag-2.2'),
+  'jquery.ui': path.join(__dirname, './node_modules/slickgrid/lib/jquery-ui-1.11.3'),
+  'flotr2': path.join(__dirname, './node_modules/flotr2/flotr2.amd'),
+  'bean': path.join(__dirname, './node_modules/flotr2/lib/bean'),
+  'jqueryui.position': path.join(__dirname, './node_modules/jquery-contextmenu/dist/jquery.ui.position'),
+  'jquery.contextmenu': path.join(__dirname, './node_modules/jquery-contextmenu/dist/jquery.contextmenu'),
+  'dropzone': path.join(__dirname, './node_modules/dropzone/dist/dropzone'),
+  'bignumber': path.join(__dirname, './node_modules/bignumber.js/bignumber'),
+
+  // AciTree
+  'jquery.acitree': path.join(__dirname, './node_modules/acitree/js/jquery.aciTree.min'),
+  'jquery.aciplugin': path.join(__dirname, './node_modules/acitree/js/jquery.aciPlugin.min'),
+  'jquery.acisortable': path.join(__dirname, './node_modules/acitree/js/jquery.aciSortable.min'),
+  'jquery.acifragment': path.join(__dirname, './node_modules/acitree/js/jquery.aciFragment.min'),
+
+  // Backbone and Backgrid
+  'backbone': path.join(__dirname, './node_modules/backbone/backbone'),
+  'backbone.undo': path.join(__dirname, './node_modules/backbone-undo/Backbone.Undo'),
+  'backform': path.join(__dirname, './node_modules/backform/src/backform'),
+  'backgrid': path.join(__dirname, './node_modules/backgrid/lib/backgrid'),
+  'bootstrap.datetimepicker': path.join(__dirname, './node_modules/bootstrap-datetime-picker/js/bootstrap-datetimepicker'),
+  'bootstrap.switch': path.join(__dirname, './node_modules/bootstrap-switch/dist/js/bootstrap-switch'),
+  'select2': path.join(__dirname, './node_modules/select2/dist/js/select2.full'),
+  'backgrid.filter': path.join(__dirname, './node_modules/backgrid-filter/backgrid-filter'),
+  'backgrid.sizeable.columns': path.join(__dirname, './node_modules/backgrid-sizeable-columns/backgrid-sizeable-columns'),
+  'backgrid.select.all': path.join(__dirname, './node_modules/backgrid-select-all/backgrid-select-all'),
+  'pgadmin.alertifyjs': path.join(__dirname, './pgadmin/static/js/alertify.pgadmin.defaults'),
+  'pgadmin.backform': path.join(__dirname, './pgadmin/static/js/backform.pgadmin'),
+  'pgadmin.backgrid': path.join(__dirname, './pgadmin/static/js/backgrid.pgadmin'),
+};
+
+let modulePaths = config['paths'];
+
+let paths = Object.assign(vendorPaths, modulePaths);
 
 var webpackShimConfig = {
   shim: {
@@ -112,156 +162,11 @@ var webpackShimConfig = {
       'deps': ['pgadmin.browser.datamodel'],
     },
   },
-
   // Map module id to file path used in 'define(['baseurl', 'misc']). It is
   // used by webpack while creating bundle
-  resolveAlias: {
-    'baseurl': path.join(__dirname, './pgadmin'),
-    'misc': path.join(__dirname, './pgadmin/static/bundle/misc'),
-    'browser_node': path.join(__dirname, './pgadmin/static/bundle/browser'),
-    'sources': path.join(__dirname, './pgadmin/static/js'),
-    'pgadmin': path.join(__dirname, './pgadmin/static/js/pgadmin'),
-    'tools.translations': path.join(__dirname, './pgadmin/tools/templates/js/translations'),
-    'sources/gettext': path.join(__dirname, './pgadmin/static/js/gettext'),
-    'babel-polyfill': path.join(__dirname, './node_modules/babel-polyfill/dist/polyfill'),
-
-    // Vendor JS
-    'jquery': path.join(__dirname, './node_modules/jquery/dist/jquery'),
-    'wcdocker': path.join(__dirname, './node_modules/webcabin-docker/Build/wcDocker'),
-    'alertify': path.join(__dirname, './node_modules/alertifyjs/build/alertify'),
-    'moment': path.join(__dirname, './node_modules/moment/moment'),
-    'jquery.event.drag': path.join(__dirname, './node_modules/slickgrid/lib/jquery.event.drag-2.2'),
-    'jquery.ui': path.join(__dirname, './node_modules/slickgrid/lib/jquery-ui-1.11.3'),
-    'flotr2': path.join(__dirname, './node_modules/flotr2/flotr2.amd'),
-    'bean': path.join(__dirname, './node_modules/flotr2/lib/bean'),
-    'jqueryui.position': path.join(__dirname, './node_modules/jquery-contextmenu/dist/jquery.ui.position'),
-    'jquery.contextmenu': path.join(__dirname, './node_modules/jquery-contextmenu/dist/jquery.contextMenu'),
-    'dropzone': path.join(__dirname, './node_modules/dropzone/dist/dropzone'),
-    'bignumber': path.join(__dirname, './node_modules/bignumber.js/bignumber'),
-
-    // AciTree
-    'jquery.acitree': path.join(__dirname, './node_modules/acitree/js/jquery.aciTree.min'),
-    'jquery.aciplugin': path.join(__dirname, './node_modules/acitree/js/jquery.aciPlugin.min'),
-    'jquery.acisortable': path.join(__dirname, './node_modules/acitree/js/jquery.aciSortable.min'),
-    'jquery.acifragment': path.join(__dirname, './node_modules/acitree/js/jquery.aciFragment.min'),
-
-    // Backbone and Backgrid
-    'backbone': path.join(__dirname, './node_modules/backbone/backbone'),
-    'backbone.undo': path.join(__dirname, './node_modules/backbone-undo/Backbone.Undo'),
-    'backform': path.join(__dirname, './node_modules/backform/src/backform'),
-    'backgrid': path.join(__dirname, './node_modules/backgrid/lib/backgrid'),
-    'bootstrap.datetimepicker': path.join(__dirname, './node_modules/bootstrap-datetime-picker/js/bootstrap-datetimepicker'),
-    'bootstrap.switch': path.join(__dirname, './node_modules/bootstrap-switch/dist/js/bootstrap-switch'),
-    'select2': path.join(__dirname, './node_modules/select2/dist/js/select2.full'),
-    'backgrid.filter': path.join(__dirname, './node_modules/backgrid-filter/backgrid-filter'),
-    'backgrid.sizeable.columns': path.join(__dirname, './node_modules/backgrid-sizeable-columns/backgrid-sizeable-columns'),
-    'backgrid.select.all': path.join(__dirname, './node_modules/backgrid-select-all/backgrid-select-all'),
-
-    'pgadmin.alertifyjs': path.join(__dirname, './pgadmin/static/js/alertify.pgadmin.defaults'),
-    'pgadmin.backform': path.join(__dirname, './pgadmin/static/js/backform.pgadmin'),
-    'pgadmin.backgrid': path.join(__dirname, './pgadmin/static/js/backgrid.pgadmin'),
-    'pgadmin.misc.explain': path.join(__dirname, './pgadmin/misc/templates/explain/js/explain'),
-    'pgadmin.settings': path.join(__dirname, './pgadmin/settings/templates/settings/settings'),
-    'pgadmin.preferences': path.join(__dirname, './pgadmin/preferences/templates/preferences/preferences'),
-    'pgadmin.dashboard': path.join(__dirname, './pgadmin/dashboard/templates/dashboard/js/dashboard'),
-    'bundled_codemirror': path.join(__dirname, './pgadmin/static/bundle/codemirror'),
-    'pgadmin.sqlfoldcode': path.join(__dirname, './pgadmin/static/js/codemirror/addon/fold/pgadmin-sqlfoldcode'),
-    'pgadmin.about': path.join(__dirname, './pgadmin/about/templates/about/about'),
-
-    //tools JS
-    'tools.backup': path.join(__dirname, './pgadmin/tools/backup/templates/backup/js/backup'),
-    'tools.restore': path.join(__dirname, './pgadmin/tools/restore/templates/restore/js/restore'),
-    'pgadmin.browser.wizard': path.join(__dirname, './pgadmin/browser/static/js/wizard'),
-    'tools.grant_wizard': path.join(__dirname, './pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard'),
-    'tools.datagrid': path.join(__dirname, './pgadmin/tools/datagrid/templates/datagrid/js/datagrid'),
-    'tools.querytool': path.join(__dirname, './pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor'),
-    'tools.maintenance': path.join(__dirname, './pgadmin/tools/maintenance/templates/maintenance/js/maintenance'),
-    'tools.import_export': path.join(__dirname, './pgadmin/tools/import_export/templates/import_export/js/import_export'),
-    'tools.debugger.ui': path.join(__dirname, './pgadmin/tools/debugger/templates/debugger/js/debugger_ui'),
-    'tools.debugger': path.join(__dirname, './pgadmin/tools/debugger/templates/debugger/js/debugger'),
-    'tools.direct': path.join(__dirname, './pgadmin/tools/debugger/templates/debugger/js/direct'),
-
-    // Misc JS
-    'misc.bgprocess': path.join(__dirname, './pgadmin/misc/bgprocess/static/js/bgprocess'),
-    'misc.file_manager': path.join(__dirname, './pgadmin/misc/file_manager/templates/file_manager/js/file_manager'),
-    'misc.file_utility': path.join(__dirname, './pgadmin/misc/file_manager/templates/file_manager/js/utility'),
-    'misc.statistics':  path.join(__dirname, './pgadmin/misc/statistics/static/js/statistics'),
-    'misc.depends':  path.join(__dirname, './pgadmin/misc/depends/static/js/depends'),
-    'misc.sql': path.join(__dirname, './pgadmin/misc/sql/static/js/sql'),
-
-    // Browser Plugins JS
-    'pgadmin.browser': path.join(__dirname, './pgadmin/browser/templates/browser/js/browser'),
-    'pgadmin.browser.error': path.join(__dirname, './pgadmin/browser/templates/browser/js/error'),
-    'pgadmin.browser.utils': path.join(__dirname, './pgadmin/browser/templates/browser/js/utils'),
-    'pgadmin.browser.server.privilege': path.join(__dirname, './pgadmin/browser/server_groups/servers/static/js/privilege'),
-    'pgadmin.browser.server.variable': path.join(__dirname, './pgadmin/browser/server_groups/servers/static/js/variable'),
-    'pgadmin.browser.collection': path.join(__dirname, './pgadmin/browser/templates/browser/js/collection'),
-    'pgadmin.browser.node': path.join(__dirname, './pgadmin/browser/templates/browser/js/node'),
-    'pgadmin.browser.node.ui': path.join(__dirname, './pgadmin/browser/static/js/node.ui'),
-    'pgadmin.browser.datamodel': path.join(__dirname, './pgadmin/browser/static/js/datamodel'),
-    'pgadmin.browser.menu': path.join(__dirname, './pgadmin/browser/static/js/menu'),
-    'pgadmin.browser.panel': path.join(__dirname, './pgadmin/browser/static/js/panel'),
-    'pgadmin.browser.frame': path.join(__dirname, './pgadmin/browser/static/js/frame'),
-    'pgadmin.tools.user_management': path.join(__dirname, './pgadmin/tools/user_management/templates/user_management/js/user_management'),
-    'slick.pgadmin.editors': path.join(__dirname, './pgadmin/static/js/slickgrid/slick.pgadmin.editors'),
-    'slick.pgadmin.formatters': path.join(__dirname, './pgadmin/static/js/slickgrid/slick.pgadmin.formatters'),
-
-    // Browser Nodes JS
-    'pgadmin.node.server_group': path.join(__dirname, './pgadmin/browser/server_groups/static/js/server-group'),
-    'pgadmin.node.server': path.join(__dirname, './pgadmin/browser/server_groups/servers/static/js/server'),
-    'pgadmin.node.database': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/static/js/database'),
-    'pgadmin.node.role': path.join(__dirname, './pgadmin/browser/server_groups/servers/roles/templates/role/js/role'),
-    'pgadmin.node.tablespace': path.join(__dirname, './pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/js/tablespaces'),
-    'pgadmin.node.resource_group': path.join(__dirname, './pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups'),
-    'pgadmin.node.cast': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/casts/static/js/cast'),
-    'pgadmin.node.event_trigger': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger'),
-    'pgadmin.node.extension': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension'),
-    'pgadmin.node.foreign_data_wrapper': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper'),
-    'pgadmin.node.language': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/languages/static/js/language'),
-    'pgadmin.node.schema': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema'),
-    'pgadmin.node.catalog': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog'),
-    'pgadmin.node.catalog_object': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object'),
-    'pgadmin.node.collation': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation'),
-    'pgadmin.node.domain': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain'),
-    'pgadmin.node.domain_constraints': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints'),
-    'pgadmin.node.foreign_table': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign-table'),
-    'pgadmin.node.fts_configuration': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration'),
-    'pgadmin.node.fts_dictionary': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary'),
-    'pgadmin.node.fts_parser': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/static/js/fts_parser'),
-    'pgadmin.node.fts_template': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template'),
-
-    'pgadmin.node.function': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function'),
-    'pgadmin.node.procedure': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure'),
-    'pgadmin.node.trigger_function': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function'),
-    'pgadmin.node.package': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package'),
-    'pgadmin.node.sequence': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence'),
-    'pgadmin.node.synonym': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym'),
-
-    'pgadmin.node.table': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table'),
-    'pgadmin.browser.table.partition.utils': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils'),
-    'pgadmin.node.type': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type'),
-    'pgadmin.node.view': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view'),
-    'pgadmin.node.mview': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview'),
-    'pgadmin.node.rule': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules'),
-    'pgadmin.node.index': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/templates/index/js/index'),
-    'pgadmin.node.trigger': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger'),
-    'pgadmin.node.column': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column'),
-    'pgadmin.node.constraints': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/templates/constraints/js/constraints'),
-    'pgadmin.node.check_constraints': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/templates/check_constraint/js/check_constraint'),
-    'pgadmin.node.exclusion_constraint': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint'),
-    'pgadmin.node.foreign_key': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key'),
-    'pgadmin.node.primary_key': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key'),
-    'pgadmin.node.unique_constraint': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint'),
-    'pgadmin.node.catalog_object_column': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/templates/catalog_object_column/js/catalog_object_column'),
-    'pgadmin.node.edbfunc': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/js/edbfunc'),
-    'pgadmin.node.edbproc': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbproc/js/edbproc'),
-    'pgadmin.node.edbvar': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/templates/edbvar/js/edbvar'),
-
-    // pgAgent jobs JS
-    'pgadmin.node.pga_job': path.join(__dirname, './pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job'),
-    'pgadmin.node.pga_schedule': path.join(__dirname, './pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule'),
-    'pgadmin.node.pga_jobstep': path.join(__dirname, './pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep'),
-  },
+  resolveAlias: paths,
+  when: config.when,
+  externals: config.externals,
   // Define list of pgAdmin common libraries to bundle them separately
   // into commons JS from app.bundle.js
   pgLibs: [
@@ -269,8 +174,8 @@ var webpackShimConfig = {
     'pgadmin.browser.server.variable', 'pgadmin.browser.collection', 'pgadmin.browser.node.ui',
     'pgadmin.browser.datamodel', 'pgadmin.browser.menu', 'pgadmin.browser.panel', 'pgadmin',
     'pgadmin.browser.frame', 'slick.pgadmin.editors', 'slick.pgadmin.formatters',
-    'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser', 'misc.file_manager',
-    'misc.file_utility', 'sources/alerts/alertify_wrapper', 'pgadmin.browser.node',
+    'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser', 'pgadmin.file_manager',
+    'pgadmin.file_utility', 'sources/alerts/alertify_wrapper', 'pgadmin.browser.node',
     'pgadmin.alertifyjs', 'pgadmin.settings', 'pgadmin.preferences', 'pgadmin.sqlfoldcode',
   ],
   // Checks whether JS module is npm module or not
