mirror of
https://github.com/Microsoft/vscode
synced 2024-06-30 23:04:56 +00:00
nls - removal of loader plugin (#219098)
This commit is contained in:
parent
ff1b0028ad
commit
2014f1ddb2
|
@ -1016,7 +1016,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"target": "src/vs/{loader.d.ts,css.ts,css.build.ts,monaco.d.ts,nls.ts,nls.build.ts,nls.mock.ts}",
|
||||
"target": "src/vs/{loader.d.ts,css.ts,css.build.ts,monaco.d.ts,nls.ts}",
|
||||
"restrictions": []
|
||||
},
|
||||
{
|
||||
|
|
|
@ -29,19 +29,17 @@ const editorEntryPoints = [
|
|||
{
|
||||
name: 'vs/editor/editor.main',
|
||||
include: [],
|
||||
exclude: ['vs/css', 'vs/nls'],
|
||||
exclude: ['vs/css'],
|
||||
prepend: [
|
||||
{ path: 'out-editor-build/vs/css.js', amdModuleId: 'vs/css' },
|
||||
{ path: 'out-editor-build/vs/nls.js', amdModuleId: 'vs/nls' }
|
||||
{ path: 'out-editor-build/vs/css.js', amdModuleId: 'vs/css' }
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'vs/base/common/worker/simpleWorker',
|
||||
include: ['vs/editor/common/services/editorSimpleWorker'],
|
||||
exclude: ['vs/nls'],
|
||||
exclude: [],
|
||||
prepend: [
|
||||
{ path: 'vs/loader.js' },
|
||||
{ path: 'vs/nls.js', amdModuleId: 'vs/nls' },
|
||||
{ path: 'vs/base/worker/workerMain.js' }
|
||||
],
|
||||
dest: 'vs/base/worker/workerMain.js'
|
||||
|
@ -99,7 +97,6 @@ const optimizeEditorAMDTask = task.define('optimize-editor-amd', optimize.optimi
|
|||
paths: {
|
||||
'vs': 'out-editor-build/vs',
|
||||
'vs/css': 'out-editor-build/vs/css.build',
|
||||
'vs/nls': 'out-editor-build/vs/nls.build',
|
||||
'vscode': 'empty:'
|
||||
}
|
||||
},
|
||||
|
@ -124,7 +121,6 @@ const createESMSourcesAndResourcesTask = task.define('extract-editor-esm', () =>
|
|||
'vs/base/worker/workerMain.ts',
|
||||
],
|
||||
renames: {
|
||||
'vs/nls.mock.ts': 'vs/nls.ts'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -95,23 +95,23 @@ const serverWithWebResources = [
|
|||
const serverEntryPoints = [
|
||||
{
|
||||
name: 'vs/server/node/server.main',
|
||||
exclude: ['vs/css', 'vs/nls']
|
||||
exclude: ['vs/css']
|
||||
},
|
||||
{
|
||||
name: 'vs/server/node/server.cli',
|
||||
exclude: ['vs/css', 'vs/nls']
|
||||
exclude: ['vs/css']
|
||||
},
|
||||
{
|
||||
name: 'vs/workbench/api/node/extensionHostProcess',
|
||||
exclude: ['vs/css', 'vs/nls']
|
||||
exclude: ['vs/css']
|
||||
},
|
||||
{
|
||||
name: 'vs/platform/files/node/watcher/watcherMain',
|
||||
exclude: ['vs/css', 'vs/nls']
|
||||
exclude: ['vs/css']
|
||||
},
|
||||
{
|
||||
name: 'vs/platform/terminal/node/ptyHostMain',
|
||||
exclude: ['vs/css', 'vs/nls']
|
||||
exclude: ['vs/css']
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -36,14 +36,10 @@ function bundle(entryPoints, config, callback) {
|
|||
const loader = loaderModule.exports;
|
||||
config.isBuild = true;
|
||||
config.paths = config.paths || {};
|
||||
if (!config.paths['vs/nls']) {
|
||||
config.paths['vs/nls'] = 'out-build/vs/nls.build';
|
||||
}
|
||||
if (!config.paths['vs/css']) {
|
||||
config.paths['vs/css'] = 'out-build/vs/css.build';
|
||||
}
|
||||
config.buildForceInvokeFactory = config.buildForceInvokeFactory || {};
|
||||
config.buildForceInvokeFactory['vs/nls'] = true;
|
||||
config.buildForceInvokeFactory['vs/css'] = true;
|
||||
loader.config(config);
|
||||
loader(['require'], (localRequire) => {
|
||||
|
@ -53,7 +49,6 @@ function bundle(entryPoints, config, callback) {
|
|||
r += '.js';
|
||||
}
|
||||
// avoid packaging the build version of plugins:
|
||||
r = r.replace('vs/nls.build.js', 'vs/nls.js');
|
||||
r = r.replace('vs/css.build.js', 'vs/css.js');
|
||||
return { path: r, amdModuleId: entry.amdModuleId };
|
||||
};
|
||||
|
|
|
@ -138,14 +138,10 @@ export function bundle(entryPoints: IEntryPoint[], config: ILoaderConfig, callba
|
|||
const loader: any = loaderModule.exports;
|
||||
config.isBuild = true;
|
||||
config.paths = config.paths || {};
|
||||
if (!config.paths['vs/nls']) {
|
||||
config.paths['vs/nls'] = 'out-build/vs/nls.build';
|
||||
}
|
||||
if (!config.paths['vs/css']) {
|
||||
config.paths['vs/css'] = 'out-build/vs/css.build';
|
||||
}
|
||||
config.buildForceInvokeFactory = config.buildForceInvokeFactory || {};
|
||||
config.buildForceInvokeFactory['vs/nls'] = true;
|
||||
config.buildForceInvokeFactory['vs/css'] = true;
|
||||
loader.config(config);
|
||||
|
||||
|
@ -156,7 +152,6 @@ export function bundle(entryPoints: IEntryPoint[], config: ILoaderConfig, callba
|
|||
r += '.js';
|
||||
}
|
||||
// avoid packaging the build version of plugins:
|
||||
r = r.replace('vs/nls.build.js', 'vs/nls.js');
|
||||
r = r.replace('vs/css.build.js', 'vs/css.js');
|
||||
return { path: r, amdModuleId: entry.amdModuleId };
|
||||
};
|
||||
|
|
|
@ -250,7 +250,6 @@ function isNameTakenInFile(node, name) {
|
|||
const skippedExportMangledFiles = [
|
||||
// Build
|
||||
'css.build',
|
||||
'nls.build',
|
||||
// Monaco
|
||||
'editorCommon',
|
||||
'editorOptions',
|
||||
|
|
|
@ -283,7 +283,6 @@ function isNameTakenInFile(node: ts.Node, name: string): boolean {
|
|||
const skippedExportMangledFiles = [
|
||||
// Build
|
||||
'css.build',
|
||||
'nls.build',
|
||||
|
||||
// Monaco
|
||||
'editorCommon',
|
||||
|
|
|
@ -53,7 +53,7 @@ function loaderPlugin(src, base, amdModuleId) {
|
|||
function loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo) {
|
||||
let loaderStream = gulp.src(`${src}/vs/loader.js`, { base: `${src}` });
|
||||
if (bundleLoader) {
|
||||
loaderStream = es.merge(loaderStream, loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css'), loaderPlugin(`${src}/vs/nls.js`, `${src}`, 'vs/nls'));
|
||||
loaderStream = es.merge(loaderStream, loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css'));
|
||||
}
|
||||
const files = [];
|
||||
const order = (f) => {
|
||||
|
@ -63,10 +63,7 @@ function loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo) {
|
|||
if (f.path.endsWith('css.js')) {
|
||||
return 1;
|
||||
}
|
||||
if (f.path.endsWith('nls.js')) {
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
return 2;
|
||||
};
|
||||
return (loaderStream
|
||||
.pipe(es.through(function (data) {
|
||||
|
|
|
@ -60,8 +60,7 @@ function loader(src: string, bundledFileHeader: string, bundleLoader: boolean, e
|
|||
if (bundleLoader) {
|
||||
loaderStream = es.merge(
|
||||
loaderStream,
|
||||
loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css'),
|
||||
loaderPlugin(`${src}/vs/nls.js`, `${src}`, 'vs/nls'),
|
||||
loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -73,10 +72,7 @@ function loader(src: string, bundledFileHeader: string, bundleLoader: boolean, e
|
|||
if (f.path.endsWith('css.js')) {
|
||||
return 1;
|
||||
}
|
||||
if (f.path.endsWith('nls.js')) {
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
return 2;
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
@ -106,10 +106,7 @@ function extractEditor(options) {
|
|||
'vs/css.build.ts',
|
||||
'vs/css.ts',
|
||||
'vs/loader.js',
|
||||
'vs/loader.d.ts',
|
||||
'vs/nls.build.ts',
|
||||
'vs/nls.ts',
|
||||
'vs/nls.mock.ts',
|
||||
'vs/loader.d.ts'
|
||||
].forEach(copyFile);
|
||||
}
|
||||
function createESMSourcesAndResources2(options) {
|
||||
|
|
|
@ -118,10 +118,7 @@ export function extractEditor(options: tss.ITreeShakingOptions & { destRoot: str
|
|||
'vs/css.build.ts',
|
||||
'vs/css.ts',
|
||||
'vs/loader.js',
|
||||
'vs/loader.d.ts',
|
||||
'vs/nls.build.ts',
|
||||
'vs/nls.ts',
|
||||
'vs/nls.mock.ts',
|
||||
'vs/loader.d.ts'
|
||||
].forEach(copyFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
function createModuleDescription(name, exclude) {
|
||||
|
||||
let excludes = ['vs/css', 'vs/nls'];
|
||||
let excludes = ['vs/css'];
|
||||
if (Array.isArray(exclude) && exclude.length > 0) {
|
||||
excludes = excludes.concat(exclude);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ exports.base = [
|
|||
{
|
||||
name: 'vs/editor/common/services/editorSimpleWorker',
|
||||
include: ['vs/base/common/worker/simpleWorker'],
|
||||
exclude: ['vs/nls'],
|
||||
exclude: [],
|
||||
prepend: [
|
||||
{ path: 'vs/loader.js' },
|
||||
{ path: 'vs/base/worker/workerMain.js' }
|
||||
|
@ -41,7 +41,7 @@ exports.base = [
|
|||
},
|
||||
{
|
||||
name: 'vs/base/common/worker/simpleWorker',
|
||||
exclude: ['vs/nls'],
|
||||
exclude: [],
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const buildMap: { [name: string]: string[] } = {};
|
||||
const buildMapKeys: { [name: string]: string[] } = {};
|
||||
const entryPoints: { [entryPoint: string]: string[] } = {};
|
||||
|
||||
export interface ILocalizeInfo {
|
||||
key: string;
|
||||
comment: string[];
|
||||
}
|
||||
|
||||
export function localize(data: ILocalizeInfo | string, message: string, ...args: (string | number | boolean | undefined | null)[]): string {
|
||||
throw new Error(`Not supported at build time!`);
|
||||
}
|
||||
|
||||
export function localize2(data: ILocalizeInfo | string, message: string, ...args: (string | number | boolean | undefined | null)[]): never {
|
||||
throw new Error(`Not supported at build time!`);
|
||||
}
|
||||
|
||||
export function getConfiguredDefaultLocale(): string | undefined {
|
||||
throw new Error(`Not supported at build time!`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by the loader at build-time
|
||||
*/
|
||||
export function load(name: string, req: AMDLoader.IRelativeRequire, load: AMDLoader.IPluginLoadCallback, config: AMDLoader.IConfigurationOptions): void {
|
||||
if (!name || name.length === 0) {
|
||||
load({ localize, localize2, getConfiguredDefaultLocale });
|
||||
} else {
|
||||
req([name + '.nls', name + '.nls.keys'], function (messages: string[], keys: string[]) {
|
||||
buildMap[name] = messages;
|
||||
buildMapKeys[name] = keys;
|
||||
load(messages);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by the loader at build-time
|
||||
*/
|
||||
export function write(pluginName: string, moduleName: string, write: AMDLoader.IPluginWriteCallback): void {
|
||||
const entryPoint = write.getEntryPoint();
|
||||
|
||||
entryPoints[entryPoint] = entryPoints[entryPoint] || [];
|
||||
entryPoints[entryPoint].push(moduleName);
|
||||
|
||||
if (moduleName !== entryPoint) {
|
||||
write.asModule(pluginName + '!' + moduleName, 'define([\'vs/nls\', \'vs/nls!' + entryPoint + '\'], function(nls, data) { return nls.create("' + moduleName + '", data); });');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by the loader at build-time
|
||||
*/
|
||||
export function writeFile(pluginName: string, moduleName: string, req: AMDLoader.IRelativeRequire, write: AMDLoader.IPluginWriteFileCallback, config: AMDLoader.IConfigurationOptions): void {
|
||||
if (entryPoints.hasOwnProperty(moduleName)) {
|
||||
const fileName = req.toUrl(moduleName + '.nls.js');
|
||||
const contents = [
|
||||
'/*---------------------------------------------------------',
|
||||
' * Copyright (c) Microsoft Corporation. All rights reserved.',
|
||||
' *--------------------------------------------------------*/'
|
||||
],
|
||||
entries = entryPoints[moduleName];
|
||||
|
||||
const data: { [moduleName: string]: string[] } = {};
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
data[entries[i]] = buildMap[entries[i]];
|
||||
}
|
||||
|
||||
contents.push('define("' + moduleName + '.nls", ' + JSON.stringify(data, null, '\t') + ');');
|
||||
write(fileName, contents.join('\r\n'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by the loader at build-time
|
||||
*/
|
||||
export function finishBuild(write: AMDLoader.IPluginWriteFileCallback): void {
|
||||
write('nls.metadata.json', JSON.stringify({
|
||||
keys: buildMapKeys,
|
||||
messages: buildMap,
|
||||
bundles: entryPoints
|
||||
}, null, '\t'));
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export interface ILocalizeInfo {
|
||||
key: string;
|
||||
comment: string[];
|
||||
}
|
||||
|
||||
export interface ILocalizedString {
|
||||
original: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
function _format(message: string, args: any[]): string {
|
||||
let result: string;
|
||||
if (args.length === 0) {
|
||||
result = message;
|
||||
} else {
|
||||
result = message.replace(/\{(\d+)\}/g, function (match, rest) {
|
||||
const index = rest[0];
|
||||
return typeof args[index] !== 'undefined' ? args[index] : match;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function localize(data: ILocalizeInfo | string, message: string, ...args: any[]): string {
|
||||
return _format(message, args);
|
||||
}
|
||||
|
||||
export function localize2(data: ILocalizeInfo | string, message: string, ...args: any[]): ILocalizedString {
|
||||
const res = _format(message, args);
|
||||
return {
|
||||
original: res,
|
||||
value: res
|
||||
};
|
||||
}
|
||||
|
||||
export function getConfiguredDefaultLocale(_: string) {
|
||||
return undefined;
|
||||
}
|
Loading…
Reference in New Issue
Block a user