mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Better support for ESM workers
This commit is contained in:
parent
66091601a5
commit
d0eaa02c0a
|
@ -93,7 +93,7 @@ gulp.task('clean-minified-editor', util.rimraf('out-editor-min'));
|
|||
gulp.task('minify-editor', ['clean-minified-editor', 'optimize-editor'], common.minifyTask('out-editor'));
|
||||
|
||||
gulp.task('clean-editor-esm', util.rimraf('out-editor-esm'));
|
||||
gulp.task('extract-editor-esm', ['clean-editor-esm'], function() {
|
||||
gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro'], function() {
|
||||
standalone.createESMSourcesAndResources({
|
||||
entryPoints: [
|
||||
'vs/editor/editor.main',
|
||||
|
|
|
@ -112,15 +112,6 @@ function createESMSourcesAndResources(options) {
|
|||
}
|
||||
var fileContents = fs.readFileSync(filename).toString();
|
||||
var info = ts.preProcessFile(fileContents);
|
||||
if (info.isLibFile) {
|
||||
console.log("1. oh no, what does this mean!!!");
|
||||
}
|
||||
if (info.typeReferenceDirectives.length > 0) {
|
||||
console.log("2. oh no, what does this mean!!!");
|
||||
}
|
||||
if (info.referencedFiles.length > 0) {
|
||||
console.log("3. oh no, what does this mean!!!");
|
||||
}
|
||||
for (var i = info.importedFiles.length - 1; i >= 0; i--) {
|
||||
var importedFilename = info.importedFiles[i].fileName;
|
||||
var pos = info.importedFiles[i].pos;
|
||||
|
|
|
@ -130,15 +130,6 @@ export function createESMSourcesAndResources(options: IOptions): void {
|
|||
let fileContents = fs.readFileSync(filename).toString();
|
||||
|
||||
const info = ts.preProcessFile(fileContents);
|
||||
if (info.isLibFile) {
|
||||
console.log(`1. oh no, what does this mean!!!`);
|
||||
}
|
||||
if (info.typeReferenceDirectives.length > 0) {
|
||||
console.log(`2. oh no, what does this mean!!!`);
|
||||
}
|
||||
if (info.referencedFiles.length > 0) {
|
||||
console.log(`3. oh no, what does this mean!!!`);
|
||||
}
|
||||
|
||||
for (let i = info.importedFiles.length - 1; i >= 0; i--) {
|
||||
const importedFilename = info.importedFiles[i].fileName;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Microsoft Corporation
|
||||
Copyright (c) 2016 - present Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
"name": "monaco-editor-core",
|
||||
"private": true,
|
||||
"version": "0.9.0",
|
||||
"version": "0.11.0",
|
||||
"description": "A browser based code editor",
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"module": "./esm/vs/editor/editor.main.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/vscode"
|
||||
|
|
|
@ -288,14 +288,23 @@ class MirrorModel extends BaseMirrorModel implements ICommonModel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface IForeignModuleFactory {
|
||||
(ctx: IWorkerContext, createData: any): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export abstract class BaseEditorSimpleWorker {
|
||||
private _foreignModuleFactory: IForeignModuleFactory;
|
||||
private _foreignModule: any;
|
||||
|
||||
constructor(foreignModule: any) {
|
||||
this._foreignModule = foreignModule;
|
||||
constructor(foreignModuleFactory: IForeignModuleFactory) {
|
||||
this._foreignModuleFactory = foreignModuleFactory;
|
||||
this._foreignModule = null;
|
||||
}
|
||||
|
||||
protected abstract _getModel(uri: string): ICommonModel;
|
||||
|
@ -474,7 +483,14 @@ export abstract class BaseEditorSimpleWorker {
|
|||
// ---- BEGIN foreign module support --------------------------------------------------------------------------
|
||||
|
||||
public loadForeignModule(moduleId: string, createData: any): TPromise<string[]> {
|
||||
if (this._foreignModule) {
|
||||
let ctx: IWorkerContext = {
|
||||
getMirrorModels: (): IMirrorModel[] => {
|
||||
return this._getModels();
|
||||
}
|
||||
};
|
||||
|
||||
if (this._foreignModuleFactory) {
|
||||
this._foreignModule = this._foreignModuleFactory(ctx, createData);
|
||||
// static foreing module
|
||||
let methods: string[] = [];
|
||||
for (let prop in this._foreignModule) {
|
||||
|
@ -486,12 +502,7 @@ export abstract class BaseEditorSimpleWorker {
|
|||
}
|
||||
return new TPromise<any>((c, e) => {
|
||||
// Use the global require to be sure to get the global config
|
||||
(<any>self).require([moduleId], (foreignModule: { create: (ctx: IWorkerContext, createData: any) => any; }) => {
|
||||
let ctx: IWorkerContext = {
|
||||
getMirrorModels: (): IMirrorModel[] => {
|
||||
return this._getModels();
|
||||
}
|
||||
};
|
||||
(<any>self).require([moduleId], (foreignModule: { create: IForeignModuleFactory }) => {
|
||||
this._foreignModule = foreignModule.create(ctx, createData);
|
||||
|
||||
let methods: string[] = [];
|
||||
|
@ -531,8 +542,8 @@ export class EditorSimpleWorkerImpl extends BaseEditorSimpleWorker implements IR
|
|||
|
||||
private _models: { [uri: string]: MirrorModel; };
|
||||
|
||||
constructor(foreignModule: any) {
|
||||
super(foreignModule);
|
||||
constructor(foreignModuleFactory: IForeignModuleFactory) {
|
||||
super(foreignModuleFactory);
|
||||
this._models = Object.create(null);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue