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-17 00:05:10 +0300
committerGitHub <noreply@github.com>2022-06-17 00:05:10 +0300
commit0d160ac2376d4c3573ec9620614d625eeb7a5694 (patch)
tree7dfe99b61cd6a35628e01b2f8719969e523f4e04 /build
parentc4623596524062960569781f5d023641be3da063 (diff)
Fix bundling (#152389)
* Ensure stable order in bundled loader.js * Avoid packaging build version of loader plugins
Diffstat (limited to 'build')
-rw-r--r--build/lib/bundle.js9
-rw-r--r--build/lib/bundle.ts9
-rw-r--r--build/lib/optimize.js40
-rw-r--r--build/lib/optimize.ts40
4 files changed, 65 insertions, 33 deletions
diff --git a/build/lib/bundle.js b/build/lib/bundle.js
index 928b6d1621f..497ac4fb67e 100644
--- a/build/lib/bundle.js
+++ b/build/lib/bundle.js
@@ -48,10 +48,13 @@ function bundle(entryPoints, config, callback) {
loader.config(config);
loader(['require'], (localRequire) => {
const resolvePath = (entry) => {
- const r = localRequire.toUrl(entry.path);
- if (!/\.js/.test(r)) {
- return { path: r + '.js', amdModuleId: entry.amdModuleId };
+ let r = localRequire.toUrl(entry.path);
+ if (!r.endsWith('.js')) {
+ 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 };
};
for (const moduleId in entryPointsMap) {
diff --git a/build/lib/bundle.ts b/build/lib/bundle.ts
index c609ef98223..c5fdc2da18c 100644
--- a/build/lib/bundle.ts
+++ b/build/lib/bundle.ts
@@ -151,10 +151,13 @@ export function bundle(entryPoints: IEntryPoint[], config: ILoaderConfig, callba
loader(['require'], (localRequire: any) => {
const resolvePath = (entry: IExtraFile) => {
- const r = localRequire.toUrl(entry.path);
- if (!/\.js/.test(r)) {
- return { path: r + '.js', amdModuleId: entry.amdModuleId };
+ let r = localRequire.toUrl(entry.path);
+ if (!r.endsWith('.js')) {
+ 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 };
};
for (const moduleId in entryPointsMap) {
diff --git a/build/lib/optimize.js b/build/lib/optimize.js
index af5f205d2d4..6a0b1804834 100644
--- a/build/lib/optimize.js
+++ b/build/lib/optimize.js
@@ -52,29 +52,41 @@ function loader(src, bundledFileHeader, bundleLoader, externalLoaderInfo) {
if (bundleLoader) {
loaderStream = es.merge(loaderStream, loaderPlugin(`${src}/vs/css.js`, `${src}`, 'vs/css'), loaderPlugin(`${src}/vs/nls.js`, `${src}`, 'vs/nls'));
}
- let isFirst = true;
- return (loaderStream
- .pipe(es.through(function (data) {
- if (isFirst) {
- isFirst = false;
- this.emit('data', new VinylFile({
- path: 'fake',
- base: '.',
- contents: Buffer.from(bundledFileHeader)
- }));
- this.emit('data', data);
+ const files = [];
+ const order = (f) => {
+ if (f.path.endsWith('loader.js')) {
+ return 0;
+ }
+ if (f.path.endsWith('css.js')) {
+ return 1;
}
- else {
- this.emit('data', data);
+ if (f.path.endsWith('nls.js')) {
+ return 2;
}
+ return 3;
+ };
+ return (loaderStream
+ .pipe(es.through(function (data) {
+ files.push(data);
}, function () {
+ files.sort((a, b) => {
+ return order(a) - order(b);
+ });
+ files.unshift(new VinylFile({
+ path: 'fake',
+ base: '.',
+ contents: Buffer.from(bundledFileHeader)
+ }));
if (externalLoaderInfo !== undefined) {
- this.emit('data', new VinylFile({
+ files.push(new VinylFile({
path: 'fake2',
base: '.',
contents: Buffer.from(`require.config(${JSON.stringify(externalLoaderInfo, undefined, 2)});`)
}));
}
+ for (const file of files) {
+ this.emit('data', file);
+ }
this.emit('end');
}))
.pipe(concat('vs/loader.js')));
diff --git a/build/lib/optimize.ts b/build/lib/optimize.ts
index 09c11015837..96f002faae8 100644
--- a/build/lib/optimize.ts
+++ b/build/lib/optimize.ts
@@ -66,29 +66,43 @@ function loader(src: string, bundledFileHeader: string, bundleLoader: boolean, e
);
}
- let isFirst = true;
+ const files: VinylFile[] = [];
+ const order = (f: VinylFile) => {
+ if (f.path.endsWith('loader.js')) {
+ return 0;
+ }
+ if (f.path.endsWith('css.js')) {
+ return 1;
+ }
+ if (f.path.endsWith('nls.js')) {
+ return 2;
+ }
+ return 3;
+ };
+
return (
loaderStream
.pipe(es.through(function (data) {
- if (isFirst) {
- isFirst = false;
- this.emit('data', new VinylFile({
- path: 'fake',
- base: '.',
- contents: Buffer.from(bundledFileHeader)
- }));
- this.emit('data', data);
- } else {
- this.emit('data', data);
- }
+ files.push(data);
}, function () {
+ files.sort((a, b) => {
+ return order(a) - order(b);
+ });
+ files.unshift(new VinylFile({
+ path: 'fake',
+ base: '.',
+ contents: Buffer.from(bundledFileHeader)
+ }));
if (externalLoaderInfo !== undefined) {
- this.emit('data', new VinylFile({
+ files.push(new VinylFile({
path: 'fake2',
base: '.',
contents: Buffer.from(`require.config(${JSON.stringify(externalLoaderInfo, undefined, 2)});`)
}));
}
+ for (const file of files) {
+ this.emit('data', file);
+ }
this.emit('end');
}))
.pipe(concat('vs/loader.js'))