Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorAlexandru Dima <alexdima@microsoft.com>2022-06-16 23:01:19 +0300
committerGitHub <noreply@github.com>2022-06-16 23:01:19 +0300
commit9db5a3674ea815acc5c8cfe916c569af977ec845 (patch)
treec163543816a458ac65dc1955951eca9703545b89 /build
parent5d9717967da42628fbb3670d5e180fed4c77122a (diff)
Bring the nls loader plugin into our sources (#152338)
Diffstat (limited to 'build')
-rw-r--r--build/filters.js2
-rw-r--r--build/gulpfile.editor.js12
-rw-r--r--build/lib/bundle.js20
-rw-r--r--build/lib/bundle.ts40
-rw-r--r--build/lib/optimize.js24
-rw-r--r--build/lib/optimize.ts31
-rw-r--r--build/lib/standalone.js5
-rw-r--r--build/lib/standalone.ts5
8 files changed, 89 insertions, 50 deletions
diff --git a/build/filters.js b/build/filters.js
index 3d72c28e10b..bee295e70c3 100644
--- a/build/filters.js
+++ b/build/filters.js
@@ -66,8 +66,6 @@ module.exports.indentationFilter = [
'!**/LICENSE.{txt,rtf}',
'!LICENSES.chromium.html',
'!**/LICENSE',
- '!src/vs/nls.js',
- '!src/vs/nls.build.js',
'!src/vs/loader.js',
'!src/vs/base/browser/dompurify/*',
'!src/vs/base/common/marked/marked.js',
diff --git a/build/gulpfile.editor.js b/build/gulpfile.editor.js
index 04b23c2ef17..eb4f55f0801 100644
--- a/build/gulpfile.editor.js
+++ b/build/gulpfile.editor.js
@@ -29,14 +29,17 @@ const editorEntryPoints = [
name: 'vs/editor/editor.main',
include: [],
exclude: ['vs/css', 'vs/nls'],
- prepend: ['out-editor-build/vs/css.js', 'out-editor-build/vs/nls.js'],
+ prepend: [
+ { path: 'out-editor-build/vs/css.js' },
+ { path: 'out-editor-build/vs/nls.js', amdModuleId: 'vs/nls' }
+ ],
},
{
name: 'vs/base/common/worker/simpleWorker',
include: ['vs/editor/common/services/editorSimpleWorker'],
exclude: ['vs/nls'],
- prepend: ['vs/loader.js'],
- append: ['vs/base/worker/workerMain'],
+ prepend: [{ path: 'vs/loader.js' }],
+ append: [{ path: 'vs/base/worker/workerMain' }],
dest: 'vs/base/worker/workerMain.js'
}
];
@@ -110,9 +113,6 @@ const createESMSourcesAndResourcesTask = task.define('extract-editor-esm', () =>
'inlineEntryPoint:0.ts',
'inlineEntryPoint:1.ts',
'vs/loader.js',
- 'vs/nls.ts',
- 'vs/nls.build.js',
- 'vs/nls.d.ts',
'vs/base/worker/workerMain.ts',
],
renames: {
diff --git a/build/lib/bundle.js b/build/lib/bundle.js
index 4cf08aef429..928b6d1621f 100644
--- a/build/lib/bundle.js
+++ b/build/lib/bundle.js
@@ -42,14 +42,17 @@ function bundle(entryPoints, config, callback) {
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) => {
- const resolvePath = (path) => {
- const r = localRequire.toUrl(path);
+ const resolvePath = (entry) => {
+ const r = localRequire.toUrl(entry.path);
if (!/\.js/.test(r)) {
- return r + '.js';
+ return { path: r + '.js', amdModuleId: entry.amdModuleId };
}
- return r;
+ return { path: r, amdModuleId: entry.amdModuleId };
};
for (const moduleId in entryPointsMap) {
const entryPoint = entryPointsMap[moduleId];
@@ -330,10 +333,13 @@ function emitEntryPoint(modulesMap, deps, entryPoint, includedModules, prepend,
plugin.writeFile(pluginName, entryPoint, req, write, {});
}
});
- const toIFile = (path) => {
- const contents = readFileAndRemoveBOM(path);
+ const toIFile = (entry) => {
+ let contents = readFileAndRemoveBOM(entry.path);
+ if (entry.amdModuleId) {
+ contents = contents.replace(/^define\(/m, `define("${entry.amdModuleId}",`);
+ }
return {
- path: path,
+ path: entry.path,
contents: contents
};
};
diff --git a/build/lib/bundle.ts b/build/lib/bundle.ts
index 4c8a3e14589..c609ef98223 100644
--- a/build/lib/bundle.ts
+++ b/build/lib/bundle.ts
@@ -42,12 +42,17 @@ interface ILoaderPluginReqFunc {
toUrl(something: string): string;
}
+export interface IExtraFile {
+ path: string;
+ amdModuleId?: string;
+}
+
export interface IEntryPoint {
name: string;
include?: string[];
exclude?: string[];
- prepend?: string[];
- append?: string[];
+ prepend?: IExtraFile[];
+ append?: IExtraFile[];
dest?: string;
}
@@ -92,6 +97,13 @@ interface IPartialBundleResult {
export interface ILoaderConfig {
isBuild?: boolean;
paths?: { [path: string]: any };
+ /*
+ * Normally, during a build, no module factories are invoked. This can be used
+ * to forcefully execute a module's factory.
+ */
+ buildForceInvokeFactory: {
+ [moduleId: string]: boolean;
+ };
}
/**
@@ -132,15 +144,18 @@ export function bundle(entryPoints: IEntryPoint[], config: ILoaderConfig, callba
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: any) => {
- const resolvePath = (path: string) => {
- const r = localRequire.toUrl(path);
+ const resolvePath = (entry: IExtraFile) => {
+ const r = localRequire.toUrl(entry.path);
if (!/\.js/.test(r)) {
- return r + '.js';
+ return { path: r + '.js', amdModuleId: entry.amdModuleId };
}
- return r;
+ return { path: r, amdModuleId: entry.amdModuleId };
};
for (const moduleId in entryPointsMap) {
const entryPoint = entryPointsMap[moduleId];
@@ -403,8 +418,8 @@ function emitEntryPoint(
deps: IGraph,
entryPoint: string,
includedModules: string[],
- prepend: string[],
- append: string[],
+ prepend: IExtraFile[],
+ append: IExtraFile[],
dest: string | undefined
): IEmitEntryPointResult {
if (!dest) {
@@ -478,10 +493,13 @@ function emitEntryPoint(
}
});
- const toIFile = (path: string): IFile => {
- const contents = readFileAndRemoveBOM(path);
+ const toIFile = (entry: IExtraFile): IFile => {
+ let contents = readFileAndRemoveBOM(entry.path);
+ if (entry.amdModuleId) {
+ contents = contents.replace(/^define\(/m, `define("${entry.amdModuleId}",`);
+ }
return {
- path: path,
+ path: entry.path,
contents: contents
};
};
diff --git a/build/lib/optimize.js b/build/lib/optimize.js
index d5b957d1195..af5f205d2d4 100644
--- a/build/lib/optimize.js
+++ b/build/lib/optimize.js
@@ -35,19 +35,25 @@ function loaderConfig() {
}
exports.loaderConfig = loaderConfig;
const IS_OUR_COPYRIGHT_REGEXP = /Copyright \(C\) Microsoft Corporation/i;
+function loaderPlugin(src, base, amdModuleId) {
+ return (gulp
+ .src(src, { base })
+ .pipe(es.through(function (data) {
+ if (amdModuleId) {
+ let contents = data.contents.toString('utf8');
+ contents = contents.replace(/^define\(/m, `define("${amdModuleId}",`);
+ data.contents = Buffer.from(contents);
+ }
+ this.emit('data', data);
+ })));
+}
function loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo) {
- let sources = [
- `${src}/vs/loader.js`
- ];
+ let loaderStream = gulp.src(`${src}/vs/loader.js`, { base: `${src}` });
if (bundleLoader) {
- sources = sources.concat([
- `${src}/vs/css.js`,
- `${src}/vs/nls.js`
- ]);
+ loaderStream = es.merge(loaderStream, loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css'), loaderPlugin(`${src}/vs/nls.js`, `${src}`, 'vs/nls'));
}
let isFirst = true;
- return (gulp
- .src(sources, { base: `${src}` })
+ return (loaderStream
.pipe(es.through(function (data) {
if (isFirst) {
isFirst = false;
diff --git a/build/lib/optimize.ts b/build/lib/optimize.ts
index fc2a2f42661..09c11015837 100644
--- a/build/lib/optimize.ts
+++ b/build/lib/optimize.ts
@@ -41,21 +41,34 @@ export function loaderConfig() {
const IS_OUR_COPYRIGHT_REGEXP = /Copyright \(C\) Microsoft Corporation/i;
+function loaderPlugin(src: string, base: string, amdModuleId: string | undefined): NodeJS.ReadWriteStream {
+ return (
+ gulp
+ .src(src, { base })
+ .pipe(es.through(function (data: VinylFile) {
+ if (amdModuleId) {
+ let contents = data.contents.toString('utf8');
+ contents = contents.replace(/^define\(/m, `define("${amdModuleId}",`);
+ data.contents = Buffer.from(contents);
+ }
+ this.emit('data', data);
+ }))
+ );
+}
+
function loader(src: string, bundledFileHeader: string, bundleLoader: boolean, externalLoaderInfo?: any): NodeJS.ReadWriteStream {
- let sources = [
- `${src}/vs/loader.js`
- ];
+ let loaderStream = gulp.src(`${src}/vs/loader.js`, { base: `${src}` });
if (bundleLoader) {
- sources = sources.concat([
- `${src}/vs/css.js`,
- `${src}/vs/nls.js`
- ]);
+ loaderStream = es.merge(
+ loaderStream,
+ loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css'),
+ loaderPlugin(`${src}/vs/nls.js`, `${src}`, 'vs/nls'),
+ );
}
let isFirst = true;
return (
- gulp
- .src(sources, { base: `${src}` })
+ loaderStream
.pipe(es.through(function (data) {
if (isFirst) {
isFirst = false;
diff --git a/build/lib/standalone.js b/build/lib/standalone.js
index 59d8fee343e..1121e56ff94 100644
--- a/build/lib/standalone.js
+++ b/build/lib/standalone.js
@@ -106,9 +106,8 @@ function extractEditor(options) {
'vs/css.ts',
'vs/loader.js',
'vs/loader.d.ts',
- 'vs/nls.build.js',
- 'vs/nls.d.ts',
- 'vs/nls.js',
+ 'vs/nls.build.ts',
+ 'vs/nls.ts',
'vs/nls.mock.ts',
].forEach(copyFile);
}
diff --git a/build/lib/standalone.ts b/build/lib/standalone.ts
index 34d2e2c9074..f2181e6f274 100644
--- a/build/lib/standalone.ts
+++ b/build/lib/standalone.ts
@@ -119,9 +119,8 @@ export function extractEditor(options: tss.ITreeShakingOptions & { destRoot: str
'vs/css.ts',
'vs/loader.js',
'vs/loader.d.ts',
- 'vs/nls.build.js',
- 'vs/nls.d.ts',
- 'vs/nls.js',
+ 'vs/nls.build.ts',
+ 'vs/nls.ts',
'vs/nls.mock.ts',
].forEach(copyFile);
}