Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

#943 - Split bundle via async imports #1123

Merged
merged 26 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a33482b
Add chunk filename
bryphe Dec 13, 2017
4322aa4
Refactor CSS to asynchronous bundle
bryphe Dec 13, 2017
f007fc2
Add tool to profile webpack bundle
bryphe Dec 13, 2017
ef75f76
Get hot reload + unit tests working
bryphe Dec 13, 2017
4e728cf
Refactor language manager to be async
bryphe Dec 13, 2017
05fefc8
Fix module definitions in tsconfig
bryphe Dec 13, 2017
b908a8c
Refactor autoclosingpairs to async import
bryphe Dec 13, 2017
92fbe70
Start refactoring additional items to async dependencies
bryphe Dec 13, 2017
0033e8c
Move command manager to an async import
bryphe Dec 13, 2017
2339f4c
Factor SharedNeovimInstance to async import
bryphe Dec 13, 2017
c8247ea
Finish making LanguageManager async, and make configuration async
bryphe Dec 13, 2017
d885b67
Move EditorManager to be async
bryphe Dec 13, 2017
93cc929
Fix plugin manager
bryphe Dec 13, 2017
bdf04a3
Merge branch 'master' into bryphe/943.1/start-split-via-async-imports
bryphe Dec 15, 2017
6f33f57
Fix some typing issues
bryphe Dec 15, 2017
93a9dad
Add oni icon to repo
bryphe Dec 16, 2017
3b985b1
Merge branch 'master' into bryphe/943.1/start-split-via-async-imports
bryphe Dec 16, 2017
3d7090a
Refactor 'startEditors' method
bryphe Dec 16, 2017
17f8197
Continue removing global dependencies
bryphe Dec 16, 2017
772edce
Externalize msgpack-lite, react, and react-dom
bryphe Dec 16, 2017
3ef5c44
Move some dependencies from dev -> production
bryphe Dec 16, 2017
0e8223e
Fix lint issue
bryphe Dec 16, 2017
1c11ea6
Make sudo/shell-env async imports
bryphe Dec 16, 2017
872bbb6
Merge master
bryphe Dec 19, 2017
9e6a5a6
Remove deleted CSS files
bryphe Dec 19, 2017
c083a95
Use tsconfig.test.json for test files
bryphe Dec 19, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,6 @@ $RECYCLE.BIN/
.merlin

yarn.lock

# Webpack stats file
stats.json
21 changes: 21 additions & 0 deletions browser/src/CSS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* CSS.ts
*
* Entry point for loading all of Oni's CSS
*/

export const activate = () => {
require("./overlay.less") // tslint:disable-line

require("./Services/ContextMenu/ContextMenu.less") // tslint:disable-line

require("./Services/Explorer/Explorer.less") // tslint:disable-line
require("./Services/Menu/Menu.less")
require("./Services/Sidebar/Sidebar.less")

require("./UI/components/Error.less")
require("./UI/components/InstallHelp.less")
require("./UI/components/QuickInfo.less")
require("./UI/components/StatusBar.less")
require("./UI/components/Tabs.less")
}
6 changes: 3 additions & 3 deletions browser/src/Editor/BufferManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "rxjs/add/operator/concatMap"
import * as Oni from "oni-api"

import { EventContext, NeovimInstance } from "./../neovim"
import { languageManager, sortTextEdits } from "./../Services/Language"
import * as LanguageManager from "./../Services/Language"
import { PromiseQueue } from "./../Services/Language/PromiseQueue"

import * as SyntaxHighlighting from "./../Services/SyntaxHighlighting"
Expand Down Expand Up @@ -94,7 +94,7 @@ export class Buffer implements Oni.Buffer {

const textEditsAsArray = textEdits instanceof Array ? textEdits : [textEdits]

const sortedEdits = sortTextEdits(textEditsAsArray)
const sortedEdits = LanguageManager.sortTextEdits(textEditsAsArray)

const deferredEdits = sortedEdits.map((te) => {
return Observable.defer(async () => {
Expand Down Expand Up @@ -186,7 +186,7 @@ export class Buffer implements Oni.Buffer {
public async getTokenAt(line: number, column: number): Promise<Oni.IToken> {
const result = await this.getLines(line, line + 1)

const tokenRegEx = languageManager.getTokenRegex(this.language)
const tokenRegEx = LanguageManager.getInstance().getTokenRegex(this.language)

const getLastMatchingCharacter = (lineContents: string, character: number, dir: number, regex: RegExp) => {
while (character > 0 && character < lineContents.length) {
Expand Down
43 changes: 22 additions & 21 deletions browser/src/Editor/NeovimEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import { Colors } from "./../Services/Colors"
import { CallbackCommand, commandManager } from "./../Services/CommandManager"
import { registerBuiltInCommands } from "./../Services/Commands"
import { Completion } from "./../Services/Completion"
import { configuration, IConfigurationValues } from "./../Services/Configuration"
import { Configuration, IConfigurationValues } from "./../Services/Configuration"
import { Errors } from "./../Services/Errors"
import { addInsertModeLanguageFunctionality, LanguageEditorIntegration, languageManager } from "./../Services/Language"
import { addInsertModeLanguageFunctionality, LanguageEditorIntegration, LanguageManager } from "./../Services/Language"
import { ISyntaxHighlighter, NullSyntaxHighlighter, SyntaxHighlighter } from "./../Services/SyntaxHighlighting"
import { getThemeManagerInstance } from "./../Services/Themes"
import { ThemeManager } from "./../Services/Themes"
import { TypingPredictionManager } from "./../Services/TypingPredictionManager"
import { workspace } from "./../Services/Workspace"

Expand Down Expand Up @@ -101,8 +101,9 @@ export class NeovimEditor extends Editor implements IEditor {

constructor(
private _colors: Colors,
private _config = configuration,
private _themeManager = getThemeManagerInstance(),
private _configuration: Configuration,
private _languageManager: LanguageManager,
private _themeManager: ThemeManager,
) {
super()

Expand All @@ -112,7 +113,7 @@ export class NeovimEditor extends Editor implements IEditor {
this._bufferManager = new BufferManager(this._neovimInstance)
this._screen = new NeovimScreen()

this._hoverRenderer = new HoverRenderer(this, this._config)
this._hoverRenderer = new HoverRenderer(this, this._configuration)

this._popupMenu = new NeovimPopupMenu(
this._neovimInstance.onShowPopupMenu,
Expand Down Expand Up @@ -151,7 +152,7 @@ export class NeovimEditor extends Editor implements IEditor {
this._windowManager = new NeovimWindowManager(this._neovimInstance)

this._neovimInstance.onYank.subscribe((yankInfo) => {
if (configuration.getValue("editor.clipboard.enabled")) {
if (this._configuration.getValue("editor.clipboard.enabled")) {
clipboard.writeText(yankInfo.regcontents.join(require("os").EOL))
}
})
Expand All @@ -163,7 +164,7 @@ export class NeovimEditor extends Editor implements IEditor {

this._neovimInstance.onLeave.subscribe(() => {
// TODO: Only leave if all editors are closed...
if (!configuration.getValue("debug.persistOnNeovimExit")) {
if (!this._configuration.getValue("debug.persistOnNeovimExit")) {
remote.getCurrentWindow().close()
}
})
Expand Down Expand Up @@ -255,10 +256,10 @@ export class NeovimEditor extends Editor implements IEditor {

addInsertModeLanguageFunctionality(this._cursorMovedI$, this._modeChanged$)

const textMateHighlightingEnabled = this._config.getValue("experimental.editor.textMateHighlighting.enabled")
const textMateHighlightingEnabled = this._configuration.getValue("experimental.editor.textMateHighlighting.enabled")
this._syntaxHighlighter = textMateHighlightingEnabled ? new SyntaxHighlighter() : new NullSyntaxHighlighter()

this._completion = new Completion(this, languageManager, configuration)
this._completion = new Completion(this, this._languageManager, this._configuration)
this._completionMenu = new CompletionMenu()

this._completion.onShowCompletionItems.subscribe((completions) => {
Expand All @@ -277,7 +278,7 @@ export class NeovimEditor extends Editor implements IEditor {
this._completion.commitItem(item)
})

this._languageIntegration = new LanguageEditorIntegration(this, this._config, languageManager)
this._languageIntegration = new LanguageEditorIntegration(this, this._configuration, this._languageManager)

this._languageIntegration.onShowHover.subscribe((hover) => {
this._hoverRenderer.showQuickInfo(hover.hover, hover.errors)
Expand Down Expand Up @@ -307,8 +308,8 @@ export class NeovimEditor extends Editor implements IEditor {
this._neovimInstance.autoCommands.executeAutoCommand("FocusGained")
})

this._onConfigChanged(this._config.getValues())
this._config.onConfigurationChanged.subscribe((newValues: Partial<IConfigurationValues>) => this._onConfigChanged(newValues))
this._onConfigChanged(this._configuration.getValues())
this._configuration.onConfigurationChanged.subscribe((newValues: Partial<IConfigurationValues>) => this._onConfigChanged(newValues))

ipcRenderer.on("menu-item-click", (_evt: any, message: string) => {
if (message.startsWith(":")) {
Expand Down Expand Up @@ -386,7 +387,7 @@ export class NeovimEditor extends Editor implements IEditor {
public async init(filesToOpen: string[]): Promise<void> {
const startOptions: INeovimStartOptions = {
runtimePaths: pluginManager.getAllRuntimePaths(),
transport: configuration.getValue("experimental.neovim.transport"),
transport: this._configuration.getValue("experimental.neovim.transport"),
}

await this._neovimInstance.start(startOptions)
Expand All @@ -395,7 +396,7 @@ export class NeovimEditor extends Editor implements IEditor {
return
}

VimConfigurationSynchronizer.synchronizeConfiguration(this._neovimInstance, this._config.getValues())
VimConfigurationSynchronizer.synchronizeConfiguration(this._neovimInstance, this._configuration.getValues())

this._themeManager.onThemeChanged.subscribe(() => {
const newTheme = this._themeManager.activeTheme
Expand Down Expand Up @@ -464,7 +465,7 @@ export class NeovimEditor extends Editor implements IEditor {

this._typingPredictionManager.clearAllPredictions()

if (newMode === "insert" && configuration.getValue("editor.typingPrediction")) {
if (newMode === "insert" && this._configuration.getValue("editor.typingPrediction")) {
this._typingPredictionManager.enable()
} else {
this._typingPredictionManager.disable()
Expand Down Expand Up @@ -532,9 +533,9 @@ export class NeovimEditor extends Editor implements IEditor {
}

private _onConfigChanged(newValues: Partial<IConfigurationValues>): void {
const fontFamily = this._config.getValue("editor.fontFamily")
const fontSize = addDefaultUnitIfNeeded(this._config.getValue("editor.fontSize"))
const linePadding = this._config.getValue("editor.linePadding")
const fontFamily = this._configuration.getValue("editor.fontFamily")
const fontSize = addDefaultUnitIfNeeded(this._configuration.getValue("editor.fontSize"))
const linePadding = this._configuration.getValue("editor.linePadding")

UI.Actions.setFont(fontFamily, fontSize)
this._neovimInstance.setFont(fontFamily, fontSize, linePadding)
Expand Down Expand Up @@ -586,8 +587,8 @@ export class NeovimEditor extends Editor implements IEditor {
}

private async _onKeyDown(key: string): Promise<void> {
if (configuration.getValue("debug.fakeLag.neovimInput")) {
await sleep(configuration.getValue("debug.fakeLag.neovimInput"))
if (this._configuration.getValue("debug.fakeLag.neovimInput")) {
await sleep(this._configuration.getValue("debug.fakeLag.neovimInput"))
}

await this._neovimInstance.input(key)
Expand Down
2 changes: 1 addition & 1 deletion browser/src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import * as fs from "fs"
import * as os from "os"
import * as path from "path"
import * as sudo from "sudo-prompt"

export const isWindows = () => os.platform() === "win32"
export const isMac = () => os.platform() === "darwin"
Expand Down Expand Up @@ -33,6 +32,7 @@ export const addToPath = async () => {
}

const _runSudoCommand = async (command: string, options: any) => {
const sudo = await import("sudo-prompt")
return new Promise(resolve => {
sudo.exec(command, options, (error: Error, stdout: string, stderr: string) => {
resolve({error, stdout, stderr})
Expand Down
4 changes: 2 additions & 2 deletions browser/src/Plugins/Api/Oni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { configuration } from "./../../Services/Configuration"
import { contextMenuManager } from "./../../Services/ContextMenu"
import { editorManager } from "./../../Services/EditorManager"
import { inputManager } from "./../../Services/InputManager"
import { languageManager } from "./../../Services/Language"
import * as LanguageManager from "./../../Services/Language"
import { menuManager } from "./../../Services/Menu"
import { recorder } from "./../../Services/Recorder"
import { statusBar } from "./../../Services/StatusBar"
Expand Down Expand Up @@ -102,7 +102,7 @@ export class Oni extends EventEmitter implements OniApi.Plugin.Api {
}

public get language(): any {
return languageManager
return LanguageManager.getInstance()
}

public get menu(): any /* TODO */ {
Expand Down
2 changes: 1 addition & 1 deletion browser/src/Plugins/Api/Process.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as ChildProcess from "child_process"
import * as shellEnv from "shell-env"

import * as Platform from "./../../Platform"
import { configuration } from "./../../Services/Configuration"
Expand All @@ -24,6 +23,7 @@ const mergeSpawnOptions = async (originalSpawnOptions: ChildProcess.ExecOptions
let existingPath: string

try {
const shellEnv = await import("shell-env")
const shellEnvironment = await shellEnv()
process.env = { ...process.env, ...shellEnvironment }
existingPath = process.env.Path || process.env.PATH
Expand Down
2 changes: 0 additions & 2 deletions browser/src/Services/ContextMenu/ContextMenuComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export interface IContextMenuProps {
highlightColor: string
}

require("./ContextMenu.less") // tslint:disable-line no-var-requires

export class ContextMenuView extends React.PureComponent<IContextMenuProps, {}> {

public render(): null | JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

import * as types from "vscode-languageserver-types"

import * as UI from "./../../UI"
import * as Selectors from "./../../UI/Selectors"
import * as UI from "./../UI"
import * as Selectors from "./../UI/Selectors"

import { ILanguageServerNotificationResponse, languageManager } from "./LanguageManager"
import { ILanguageServerNotificationResponse, LanguageManager } from "./Language"

import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpers"
import * as Helpers from "./../Plugins/Api/LanguageClient/LanguageClientHelpers"

import * as Utility from "./../../Utility"
import * as Utility from "./../Utility"

interface IPublishDiagnosticsParams {
uri: string
Expand All @@ -35,7 +35,7 @@ export class DiagnosticsDataSource {
}
}

export const listenForDiagnostics = () => {
export const activate = (languageManager: LanguageManager) => {
languageManager.subscribeToLanguageServerNotification("textDocument/publishDiagnostics", (args: ILanguageServerNotificationResponse) => {
const test = args.payload as IPublishDiagnosticsParams

Expand Down
4 changes: 3 additions & 1 deletion browser/src/Services/Language/CodeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as types from "vscode-languageserver-types"
// import * as UI from "./../../UI"

import { contextMenuManager } from "./../ContextMenu"
import { languageManager } from "./LanguageManager"
import * as LanguageManager from "./LanguageManager"

import * as Log from "./../../Log"
import { editorManager } from "./../EditorManager"
Expand All @@ -25,6 +25,7 @@ let lastFileInfo: any = {}
codeActionsContextMenu.onItemSelected.subscribe(async (selectedItem) => {

const commandName = selectedItem.data
const languageManager = LanguageManager.getInstance()
await languageManager.sendLanguageServerRequest(lastFileInfo.language, lastFileInfo.filePath, "workspace/executeCommand", { command: commandName })
})

Expand Down Expand Up @@ -57,6 +58,7 @@ const getCodeActions = async (): Promise<types.Command[]> => {
return null
}

const languageManager = LanguageManager.getInstance()
if (languageManager.isLanguageServerAvailable(language)) {
let result: types.Command[] = null
try {
Expand Down
3 changes: 2 additions & 1 deletion browser/src/Services/Language/FindAllReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as types from "vscode-languageserver-types"
import { INeovimInstance } from "./../../neovim"

import { editorManager } from "./../EditorManager"
import { languageManager } from "./LanguageManager"
import * as LanguageManager from "./LanguageManager"

import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpers"

Expand All @@ -29,6 +29,7 @@ export const findAllReferences = async () => {
return
}

const languageManager = LanguageManager.getInstance()
if (languageManager.isLanguageServerAvailable(activeBuffer.language)) {
const args = { ...Helpers.bufferToTextDocumentPositionParams(activeBuffer),
context: {
Expand Down
8 changes: 4 additions & 4 deletions browser/src/Services/Language/Formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpe

import { editorManager } from "./../EditorManager"

import { languageManager } from "./LanguageManager"
import * as LanguageManager from "./LanguageManager"

export const format = async () => {

const activeBuffer = editorManager.activeEditor.activeBuffer

const capabilities = await languageManager.getCapabilitiesForLanguage(activeBuffer.language)
const capabilities = await LanguageManager.getInstance().getCapabilitiesForLanguage(activeBuffer.language)

if (capabilities.documentFormattingProvider) {
await formatDocument()
Expand All @@ -37,7 +37,7 @@ export const formatDocument = async () => {

let result: types.TextEdit[] = null
try {
result = await languageManager.sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/formatting", args)
result = await LanguageManager.getInstance().sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/formatting", args)
} catch (ex) {
Log.warn(ex)
}
Expand All @@ -60,7 +60,7 @@ export const rangeFormatDocument = async () => {

let result: types.TextEdit[] = null
try {
result = await languageManager.sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/rangeFormatting", args)
result = await LanguageManager.getInstance().sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/rangeFormatting", args)
} catch (ex) {
Log.warn(ex)
}
Expand Down
2 changes: 1 addition & 1 deletion browser/src/Services/Language/HoverRequestor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpe

import { LanguageManager } from "./LanguageManager"

import { DiagnosticsDataSource, IDiagnosticsDataSource } from "./Diagnostics"
import { DiagnosticsDataSource, IDiagnosticsDataSource } from "./../Diagnostics"

export interface IHoverResult {
hover: types.Hover
Expand Down
4 changes: 2 additions & 2 deletions browser/src/Services/Language/LanguageConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as Log from "./../../Log"

import { LanguageClient } from "./LanguageClient"
import { InitializationOptions, LanguageClientProcess, ServerRunOptions } from "./LanguageClientProcess"
import { languageManager } from "./LanguageManager"
import * as LanguageManager from "./LanguageManager"

import { getRootProjectFileFunc } from "./../../Utility"

Expand Down Expand Up @@ -97,5 +97,5 @@ const createLanguageClientFromConfig = (language: string, config: ILightweightLa
rootPath: pathResolver,
}
const languageClient = new LanguageClient(language, new LanguageClientProcess(serverRunOptions, initializationOptions, configuration))
languageManager.registerLanguageClient(language, languageClient)
LanguageManager.getInstance().registerLanguageClient(language, languageClient)
}
Loading