mirror of https://github.com/microsoft/vscode.git
Fix bundling (#152389)
* Ensure stable order in bundled loader.js * Avoid packaging build version of loader plugins
This commit is contained in:
parent
c462359652
commit
0d160ac237
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
const files = [];
|
||||
const order = (f) => {
|
||||
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')));
|
||||
|
|
|
@ -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'))
|
||||
|
|
Loading…
Reference in New Issue