Skip to content
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

Transpile theia to ES2017 #9436

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<a name="breaking_changes_1.17.0">[Breaking Changes:](#breaking_changes_1.17.0)</a>

- [core] registering toolbar items for commands that explicitly target a `ViewContainer` rather than a child widget may not behave as expected. Such registrations should be made in the `ViewContainer` by overriding the `updateToolbarItems` method and using the `registerToolbarItem` utility. See the modifications to the `scm` and `vsx-registry` packages in the PR for examples. [#9798](https://github.com/eclipse-theia/theia/pull/9798)
- [core] moved from ES5 to ES2017 [#9436](https://github.com/eclipse-theia/theia/pull/9436) - Contributed on behalf of STMicroelectronics
- [vsx-registry] `VSXExtensionsContribution` no longer implements `TabBarToolbarContribution` and is not bound as such. Extensions of the class that expect such behavior should reimplement it with caution. See caveats in PR. [#9798](https://github.com/eclipse-theia/theia/pull/9798)
- [core] `handleExpansionToggleDblClickEvent` in `TreeWidget` can no longer be overridden. Instead, `doHandleExpansionToggleDblClickEvent` can be overridden. [#9877](https://github.com/eclipse-theia/theia/pull/9877)
- [core] `ViewContainerPart` methods and properties related to hiding and showing toolbar removed: `toHideToolbar`, `hideToolbar`, `showToolbar`, `toolbarHidden`. `ViewContainerPart` toolbars are now hidden or shown using CSS properties. [#9935](https://github.com/eclipse-theia/theia/pull/9935)
Expand Down
4 changes: 2 additions & 2 deletions configs/base.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"resolveJsonModule": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"target": "ES2017",
"jsx": "react",
"lib": [
"es6",
"ES2017",
"dom"
],
"sourceMap": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,6 @@ module.exports = {
{
test: /\\.plist$/,
type: 'asset/resource'
},
{
test: /\\.js$/,
// include only es6 dependencies to transpile them to es5 classes
include: /vscode-ws-jsonrpc|vscode-jsonrpc|vscode-languageserver-protocol|vscode-languageserver-types/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
// reuse runtime babel lib instead of generating it in each js file
'@babel/plugin-transform-runtime',
// ensure that classes are transpiled
'@babel/plugin-transform-classes'
],
// see https://github.com/babel/babel/issues/8900#issuecomment-431240426
sourceType: 'unambiguous',
cacheDirectory: true
}
}
}
]
},
Expand Down
21 changes: 21 additions & 0 deletions doc/Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ Please see the latest version (`master`) for the most up-to-date information.

## Guide

### v1.17.0

#### ES2017

- Theia was updated to ES2017
- es5 VS Code extensions and Theia plugins are still supported
- If you require an es5 codebase you should be able to transpile back to es5 using webpack
tsmaeder marked this conversation as resolved.
Show resolved Hide resolved
- The following code transpiles back to an es2015 codebase:
```
config.module.rules.push({
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', { targets: { chrome: '58', ie: '11' } }]],
}
}
});
```
- Replace the targets with the ones that are needed for your use case

### v1.16.0

[Release](https://github.com/eclipse-theia/theia/releases/tag/v1.16.0)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/navigatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export namespace NavigatableWidget {
return arg instanceof BaseWidget && Navigatable.is(arg);
}
export function* getAffected<T extends Widget>(
widgets: IterableIterator<T> | ArrayLike<T>,
widgets: Iterable<T>,
context: MaybeArray<URI>
): IterableIterator<[URI, T & NavigatableWidget]> {
const uris = Array.isArray(context) ? context : [context];
return get(widgets, resourceUri => uris.some(uri => uri.isEqualOrParent(resourceUri)));
}
export function* get<T extends Widget>(
widgets: IterableIterator<T> | ArrayLike<T>,
widgets: Iterable<T>,
filter: (resourceUri: URI) => boolean = () => true
): IterableIterator<[URI, T & NavigatableWidget]> {
for (const widget of widgets) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/saveable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ export namespace SaveableWidget {
export function is(widget: Widget | undefined): widget is SaveableWidget {
return !!widget && 'closeWithoutSaving' in widget;
}
export function getDirty<T extends Widget>(widgets: IterableIterator<T> | ArrayLike<T>): IterableIterator<SaveableWidget & T> {
export function getDirty<T extends Widget>(widgets: Iterable<T>): IterableIterator<SaveableWidget & T> {
return get(widgets, Saveable.isDirty);
}
export function* get<T extends Widget>(
widgets: IterableIterator<T> | ArrayLike<T>,
widgets: Iterable<T>,
filter: (widget: T) => boolean = () => true
): IterableIterator<SaveableWidget & T> {
for (const widget of widgets) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/tree/tree-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
decorations.push(node.decorationData);
}
if (this.decorations.has(node.id)) {
decorations.push(...this.decorations.get(node.id));
decorations.push(...this.decorations.get(node.id)!);
}
return decorations.sort(TreeDecoration.Data.comparePriority);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ before(() => {
testContainer.bind(WorkspaceVariableContribution).toSelf().inSingletonScope();
testContainer.bind(ApplicationShell).toConstantValue({
currentChanged: new Signal({}),
widgets: () => []
widgets: []
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
testContainer.bind(WidgetManager).toConstantValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ export class PluginContributionHandler {
}
}

if (contributions.colors) {
pushContribution('colors', () => this.colors.register(...contributions.colors));
const colors = contributions.colors;
if (colors) {
pushContribution('colors', () => this.colors.register(...colors));
}

if (contributions.taskDefinitions) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/command-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class CommandRegistryImpl implements CommandRegistryExt {
// Using the KnownCommand exclusions, convert the commands manually
return KnownCommands.map(id, args, (mappedId: string, mappedArgs: any[] | undefined, mappedResult: KnownCommands.ConversionFunction) => {
const mr: KnownCommands.ConversionFunction = mappedResult;
return this.proxy.$executeCommand(mappedId, ...mappedArgs).then((result: any) => {
return this.proxy.$executeCommand(mappedId, ...mappedArgs || []).then((result: any) => {
if (!result) {
return undefined;
}
Expand Down
Loading