-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: fix bugs, enable in demo app, update Monaco #10973
Changes from 4 commits
da81d25
f6514bd
c051be4
ab937ad
ae62082
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { createDemoApp } from '@uifabric/example-app-base'; | ||
import { configureEnvironment } from '@uifabric/tsx-editor'; | ||
import { AppDefinition } from './AppDefinition'; | ||
import { GettingStartedPage } from './GettingStartedPage'; | ||
|
||
// Configure example editor | ||
configureEnvironment({ baseUrl: '.', useMinified: false }); | ||
|
||
createDemoApp(AppDefinition, GettingStartedPage); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
let path = require('path'); | ||
const resources = require('../../scripts/webpack/webpack-resources'); | ||
const resources = require('@uifabric/build/webpack/webpack-resources'); | ||
const { addMonacoWebpackConfig } = require('@uifabric/tsx-editor/scripts/addMonacoWebpackConfig'); | ||
|
||
const BUNDLE_NAME = 'office-ui-fabric-react'; | ||
const IS_PRODUCTION = process.argv.indexOf('--production') > -1; | ||
|
||
module.exports = [ | ||
...resources.createConfig(BUNDLE_NAME, IS_PRODUCTION, { | ||
entry: { [BUNDLE_NAME]: './lib/index.bundle.js' }, | ||
...resources.createConfig( | ||
BUNDLE_NAME, | ||
IS_PRODUCTION, | ||
addMonacoWebpackConfig({ | ||
entry: { [BUNDLE_NAME]: './lib/index.js' }, | ||
|
||
output: { | ||
libraryTarget: 'var', | ||
library: 'Fabric' | ||
}, | ||
|
||
externals: [ | ||
{ | ||
react: 'React' | ||
output: { | ||
libraryTarget: 'var', | ||
library: 'Fabric' | ||
}, | ||
{ | ||
|
||
externals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM' | ||
} | ||
], | ||
}, | ||
|
||
resolve: { | ||
alias: { | ||
'office-ui-fabric-react$': path.resolve(__dirname, '../../packages/office-ui-fabric-react/lib'), | ||
'office-ui-fabric-react/src': path.resolve(__dirname, '../../packages/office-ui-fabric-react/src'), | ||
'office-ui-fabric-react/lib': path.resolve(__dirname, '../../packages/office-ui-fabric-react/lib'), | ||
'@uifabric/api-docs/lib': path.resolve(__dirname, '../../packages/api-docs/lib'), | ||
'Props.ts.js': 'Props', | ||
'Example.tsx.js': 'Example' | ||
resolve: { | ||
alias: { | ||
'office-ui-fabric-react$': path.resolve(__dirname, '../../packages/office-ui-fabric-react/lib'), | ||
'office-ui-fabric-react/src': path.resolve(__dirname, '../../packages/office-ui-fabric-react/src'), | ||
'office-ui-fabric-react/lib': path.resolve(__dirname, '../../packages/office-ui-fabric-react/lib'), | ||
'@uifabric/api-docs/lib': path.resolve(__dirname, '../../packages/api-docs/lib'), | ||
'Props.ts.js': 'Props', | ||
'Example.tsx.js': 'Example' | ||
} | ||
} | ||
} | ||
}), | ||
}) | ||
), | ||
require('./webpack.serve.config') | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
const getResolveAlias = require('../../scripts/webpack/getResolveAlias'); | ||
const resources = require('../../scripts/webpack/webpack-resources'); | ||
const getResolveAlias = require('@uifabric/build/webpack/getResolveAlias'); | ||
const resources = require('@uifabric/build/webpack/webpack-resources'); | ||
const { addMonacoWebpackConfig } = require('@uifabric/tsx-editor/scripts/addMonacoWebpackConfig'); | ||
|
||
module.exports = resources.createServeConfig({ | ||
entry: './src/index.tsx', | ||
const BUNDLE_NAME = 'demo-app'; | ||
|
||
output: { | ||
filename: 'demo-app.js' | ||
}, | ||
module.exports = resources.createServeConfig( | ||
addMonacoWebpackConfig({ | ||
entry: { | ||
[BUNDLE_NAME]: './src/index.tsx' | ||
}, | ||
|
||
externals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM' | ||
}, | ||
externals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM' | ||
}, | ||
|
||
resolve: { | ||
alias: getResolveAlias() | ||
} | ||
}); | ||
resolve: { | ||
alias: getResolveAlias() | ||
} | ||
}) | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "none", | ||
"comment": "Add missing tsx-editor dev dep", | ||
"packageName": "@uifabric/fabric-website", | ||
"email": "[email protected]", | ||
"commit": "da81d25a70517a242b31f2b25ee8b07975b6e539", | ||
"date": "2019-10-26T19:41:23.322Z" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Enable live editor and update bundling", | ||
"packageName": "@uifabric/fabric-website-resources", | ||
"email": "[email protected]", | ||
"commit": "da81d25a70517a242b31f2b25ee8b07975b6e539", | ||
"date": "2019-10-26T19:41:10.088Z" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Pick up new Monaco version and try a different cross-domain worker loading method", | ||
"packageName": "@uifabric/monaco-editor", | ||
"email": "[email protected]", | ||
"commit": "da81d25a70517a242b31f2b25ee8b07975b6e539", | ||
"date": "2019-10-26T19:41:34.548Z" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Fix some minor bugs", | ||
"packageName": "@uifabric/tsx-editor", | ||
"email": "[email protected]", | ||
"commit": "da81d25a70517a242b31f2b25ee8b07975b6e539", | ||
"date": "2019-10-26T19:51:04.006Z" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
// This file was generated by checking out and building monaco-typescript (https://github.com/Microsoft/monaco-typescript) | ||
// and merging release/esm/*.d.ts together, with minor edits. | ||
// This file may need to be re-generated when updating the monaco-editor version. Steps: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a PR in monaco-typescript to make this slightly easier, but for now it seemed good to specify the full manual process. |
||
// 1. Clone https://github.com/Microsoft/monaco-typescript | ||
// 2. npm install | ||
// 3. Edit src/tsconfig.json and src/tsconfig.esm.json to include "declaration": true | ||
// 4. npm run compile | ||
// 5. Merge .d.ts files from release/esm into this file (unfortunately a manual process right now) | ||
// 6. Resolve any type mismatch issues (likely caused by mismatches between our TS version and Monaco's) | ||
|
||
// merged imports from all files | ||
import * as ts from 'typescript'; | ||
|
@@ -19,14 +24,15 @@ import { Omit } from '@uifabric/utilities'; | |
export type EmitOutput = ts.EmitOutput; | ||
|
||
// languageFeatures.d.ts | ||
export declare function flattenDiagnosticMessageText(diag: string | ts.DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; | ||
export declare abstract class Adapter { | ||
protected _worker: (first: Uri, ...more: Uri[]) => Promise<TypeScriptWorker>; | ||
constructor(_worker: (first: Uri, ...more: Uri[]) => Promise<TypeScriptWorker>); | ||
protected _positionToOffset(uri: Uri, position: monaco.IPosition): number; | ||
protected _offsetToPosition(uri: Uri, offset: number): monaco.IPosition; | ||
protected _textSpanToRange(uri: Uri, span: ts.TextSpan): monaco.IRange; | ||
} | ||
export declare class DiagnostcsAdapter extends Adapter { | ||
export declare class DiagnosticsAdapter extends Adapter { | ||
private _defaults; | ||
private _selector; | ||
private _disposables; | ||
|
@@ -35,6 +41,7 @@ export declare class DiagnostcsAdapter extends Adapter { | |
dispose(): void; | ||
private _doValidate; | ||
private _convertDiagnostics; | ||
private _tsDiagnosticCategoryToMarkerSeverity; | ||
} | ||
export declare class SuggestAdapter extends Adapter implements monaco.languages.CompletionItemProvider { | ||
readonly triggerCharacters: string[]; | ||
|
@@ -44,7 +51,7 @@ export declare class SuggestAdapter extends Adapter implements monaco.languages. | |
} | ||
export declare class SignatureHelpAdapter extends Adapter implements monaco.languages.SignatureHelpProvider { | ||
signatureHelpTriggerCharacters: string[]; | ||
provideSignatureHelp(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.SignatureHelp>; | ||
provideSignatureHelp(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.SignatureHelpResult>; | ||
} | ||
export declare class QuickInfoAdapter extends Adapter implements monaco.languages.HoverProvider { | ||
provideHover(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.Hover>; | ||
|
@@ -105,6 +112,13 @@ export declare class FormatOnTypeAdapter extends FormatHelper implements monaco. | |
readonly autoFormatTriggerCharacters: string[]; | ||
provideOnTypeFormattingEdits(model: monaco.editor.IReadOnlyModel, position: Position, ch: string, options: monaco.languages.FormattingOptions, token: CancellationToken): Thenable<ISingleEditOperation[]>; | ||
} | ||
export declare class CodeActionAdaptor extends FormatHelper implements monaco.languages.CodeActionProvider { | ||
provideCodeActions(model: monaco.editor.ITextModel, range: Range, context: monaco.languages.CodeActionContext, token: CancellationToken): Promise<monaco.languages.CodeActionList>; | ||
private _tsCodeFixActionToMonacoCodeAction; | ||
} | ||
export declare class RenameAdapter extends Adapter implements monaco.languages.RenameProvider { | ||
provideRenameEdits(model: monaco.editor.ITextModel, position: Position, newName: string, token: CancellationToken): Promise<monaco.languages.WorkspaceEdit & monaco.languages.Rejection>; | ||
} | ||
|
||
// monaco.contribution.d.ts | ||
export interface IExtraLib { | ||
|
@@ -164,6 +178,7 @@ export declare class TypeScriptWorker implements ts.LanguageServiceHost { | |
private static clearFiles; | ||
getSyntacticDiagnostics(fileName: string): Promise<ts.Diagnostic[]>; | ||
getSemanticDiagnostics(fileName: string): Promise<ts.Diagnostic[]>; | ||
getSuggestionDiagnostics(fileName: string): Promise<ts.DiagnosticWithLocation[]>; | ||
getCompilerOptionsDiagnostics(fileName: string): Promise<ts.Diagnostic[]>; | ||
getCompletionsAtPosition(fileName: string, position: number): Promise<ts.CompletionInfo>; | ||
getCompletionEntryDetails(fileName: string, position: number, entry: string): Promise<ts.CompletionEntryDetails>; | ||
|
@@ -176,7 +191,10 @@ export declare class TypeScriptWorker implements ts.LanguageServiceHost { | |
getFormattingEditsForDocument(fileName: string, options: ts.FormatCodeOptions): Promise<ts.TextChange[]>; | ||
getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): Promise<ts.TextChange[]>; | ||
getFormattingEditsAfterKeystroke(fileName: string, postion: number, ch: string, options: ts.FormatCodeOptions): Promise<ts.TextChange[]>; | ||
findRenameLocations(fileName: string, positon: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename: boolean): Promise<readonly ts.RenameLocation[]>; | ||
getRenameInfo(fileName: string, positon: number, options: ts.RenameInfoOptions): Promise<ts.RenameInfo>; | ||
getEmitOutput(fileName: string): Promise<ts.EmitOutput>; | ||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: ts.FormatCodeOptions): Promise<ReadonlyArray<ts.CodeFixAction>>; | ||
updateExtraLibs(extraLibs: IExtraLibs): void; | ||
} | ||
export interface ICreateData { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,11 @@ | |
"just": "just-scripts" | ||
}, | ||
"devDependencies": { | ||
"monaco-editor": "0.18.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. monaco shouldn't be a production dependency since we're copying out all the relevant files and re-publishing |
||
"@uifabric/build": "^7.0.0" | ||
}, | ||
"dependencies": { | ||
"@microsoft/load-themed-styles": "^1.7.13", | ||
"monaco-editor": "0.17.1", | ||
"tslib": "^1.7.1" | ||
}, | ||
"optionalPeerDependencies": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,25 @@ function addMonacoWebpackConfig(config, includeAllLanguages) { | |
throw new Error('config passed to addMonacoConfig must be an object, not an array or function.'); | ||
} | ||
|
||
const { entry, output, resolve } = config; | ||
const { entry, output, externals, resolve } = config; | ||
if (!entry || typeof entry !== 'object') { | ||
throw new Error(`config.entry passed to addMonacoWebpackConfig must be an object. Got: ${JSON.stringify(entry)}`); | ||
} | ||
|
||
// As of [email protected], typescriptServices.js includes a direct require for this package, | ||
// which breaks webpack. Use an external to get rid of it (this works since the require is | ||
// wrapped in a try/catch). Will be fixed once this merges and is published. | ||
// https://github.com/microsoft/monaco-typescript/pull/49 | ||
/** @type {webpack.ExternalsElement[]} */ | ||
const newExternals = [{ '@microsoft/typescript-etw': 'FakeModule' }]; | ||
if (externals) { | ||
if (Array.isArray(externals)) { | ||
newExternals.push(...externals); | ||
} else { | ||
newExternals.push(externals); | ||
} | ||
} | ||
|
||
// Somewhat based on https://github.com/microsoft/monaco-editor/blob/master/docs/integrate-esm.md | ||
return { | ||
...config, | ||
|
@@ -40,6 +54,7 @@ function addMonacoWebpackConfig(config, includeAllLanguages) { | |
} | ||
: {}) | ||
}, | ||
externals: newExternals, | ||
output: { | ||
...output, | ||
globalObject: 'self' // required for monaco--see https://github.com/webpack/webpack/issues/6642 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addMonacoWebpackConfig requires
entry
to be an object