Use PATH_PREFIX correctly in dev-setup

This commit is contained in:
Alex Dima 2019-03-01 12:52:42 +01:00
parent f0832de23a
commit 7edb4d6f13

View file

@ -55,23 +55,25 @@
Component.prototype.isRelease = function() { Component.prototype.isRelease = function() {
return /release/.test(this.selectedPath); return /release/.test(this.selectedPath);
}; };
Component.prototype.getResolvedPath = function() { Component.prototype.getResolvedPath = function(PATH_PREFIX) {
let resolvedPath = this.paths[this.selectedPath]; let resolvedPath = this.paths[this.selectedPath];
if (this.selectedPath === 'npm/dev' || this.selectedPath === 'npm/min' || this.isRelease()) { if (this.selectedPath === 'npm/dev' || this.selectedPath === 'npm/min' || this.isRelease()) {
if (IS_FILE_PROTOCOL) { if (IS_FILE_PROTOCOL) {
resolvedPath = DIRNAME + '/../' + resolvedPath; resolvedPath = DIRNAME + '/../' + resolvedPath;
} else { } else {
resolvedPath = '/monaco-editor/' + resolvedPath; resolvedPath = PATH_PREFIX + '/monaco-editor/' + resolvedPath;
} }
} else { } else {
if (IS_FILE_PROTOCOL) { if (IS_FILE_PROTOCOL) {
resolvedPath = DIRNAME + '/../..' + resolvedPath; resolvedPath = DIRNAME + '/../..' + resolvedPath;
} else {
resolvedPath = PATH_PREFIX + resolvedPath;
} }
} }
return resolvedPath; return resolvedPath;
}; };
Component.prototype.generateLoaderConfig = function(dest) { Component.prototype.generateLoaderConfig = function(dest, PATH_PREFIX) {
dest[this.modulePrefix] = this.getResolvedPath(); dest[this.modulePrefix] = this.getResolvedPath(PATH_PREFIX);
}; };
Component.prototype.generateUrlForPath = function(pathName) { Component.prototype.generateUrlForPath = function(pathName) {
let NEW_LOADER_OPTS = {}; let NEW_LOADER_OPTS = {};
@ -103,7 +105,7 @@
let RESOLVED_CORE = new Component('editor', 'vs', METADATA.CORE.paths); let RESOLVED_CORE = new Component('editor', 'vs', METADATA.CORE.paths);
self.RESOLVED_CORE_PATH = RESOLVED_CORE.getResolvedPath(); self.RESOLVED_CORE_PATH = RESOLVED_CORE.getResolvedPath('');
let RESOLVED_PLUGINS = METADATA.PLUGINS.map(function(plugin) { let RESOLVED_PLUGINS = METADATA.PLUGINS.map(function(plugin) {
return new Component(plugin.name, plugin.modulePrefix, plugin.paths, plugin.contrib); return new Component(plugin.name, plugin.modulePrefix, plugin.paths, plugin.contrib);
}); });
@ -151,14 +153,14 @@
self.loadEditor = function(callback, PATH_PREFIX) { self.loadEditor = function(callback, PATH_PREFIX) {
PATH_PREFIX = PATH_PREFIX || ''; PATH_PREFIX = PATH_PREFIX || '';
loadScript(PATH_PREFIX + RESOLVED_CORE.getResolvedPath() + '/loader.js', function() { loadScript(RESOLVED_CORE.getResolvedPath(PATH_PREFIX) + '/loader.js', function() {
let loaderPathsConfig = {}; let loaderPathsConfig = {};
if (!RESOLVED_CORE.isRelease()) { if (!RESOLVED_CORE.isRelease()) {
RESOLVED_PLUGINS.forEach(function(plugin) { RESOLVED_PLUGINS.forEach(function(plugin) {
plugin.generateLoaderConfig(loaderPathsConfig); plugin.generateLoaderConfig(loaderPathsConfig, PATH_PREFIX);
}); });
} }
RESOLVED_CORE.generateLoaderConfig(loaderPathsConfig); RESOLVED_CORE.generateLoaderConfig(loaderPathsConfig, PATH_PREFIX);
console.log('LOADER CONFIG: '); console.log('LOADER CONFIG: ');
console.log(JSON.stringify(loaderPathsConfig, null, '\t')); console.log(JSON.stringify(loaderPathsConfig, null, '\t'));