Skip to content

Commit 7f6843a

Browse files
authored
chore: update deps (#351)
* bump deps * unify deps * reduce bundle size * remove more deps from worker version * remove extra deps * fix lodash issues * silent lodash errors * side-effect with process name * update ts version * comment babel externals * unify babel-core * fix semver * fix more workers
1 parent 7a1dfee commit 7f6843a

18 files changed

+431
-444
lines changed

fix-worker-bundle.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
const fs = require('fs');
22
const entry = './dist/bundled/start-worker-server.js';
3-
const vars = [
4-
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
5-
'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
6-
'Z', '_'
7-
]
3+
const vars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_'];
84

95
const stringsToRemove = vars.map((e) => {
10-
return vars.map(e_ => {
11-
return `t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(${e}&&e[${e}]){var t;if("function"!=typeof(t=e[${e}]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,${e},{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],s=0;s<arguments.length;s++)i.push(arguments[s]);i.push((function(e,n){e?r(e):t(n)}));try{e.apply(this,i)}catch(e){r(e)}return n}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),${e}&&Object.defineProperty(t,${e},{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,${e_.toLowerCase()}(e))}`.trim().toString();
12-
})
6+
return vars.map((e_) => {
7+
return `t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(${e}&&e[${e}]){var t;if("function"!=typeof(t=e[${e}]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,${e},{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],s=0;s<arguments.length;s++)i.push(arguments[s]);i.push((function(e,n){e?r(e):t(n)}));try{e.apply(this,i)}catch(e){r(e)}return n}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),${e}&&Object.defineProperty(t,${e},{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,${e_.toLowerCase()}(e))}`
8+
.trim()
9+
.toString();
10+
});
1311
});
1412

1513
const stringToFix = 't.promisify=function(e){}';
@@ -26,7 +24,8 @@ if (content !== fixedContent) {
2624
console.log('Worker bundle patched');
2725
} else {
2826
if (!content.includes(stringToFix)) {
29-
throw new Error('Unable to fix worker bundle');
27+
console.info('Worker bundle already patched');
28+
// throw new Error('Unable to fix worker bundle');
3029
} else {
3130
console.log('Worker bundle already patched');
3231
}

package.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@
2424
"bin": "bin/ember-language-server.js",
2525
"main": "lib/index.js",
2626
"typings": "lib/index.d.ts",
27+
"resolutions": {
28+
"@babel/parser": "^7.17.0",
29+
"@babel/traverse": "^7.17.0",
30+
"@babel/core": "^7.17.0"
31+
},
2732
"dependencies": {
2833
"@glimmer/syntax": "^0.83.1",
29-
"@lifeart/ember-extract-inline-templates": "2.1.0",
30-
"ast-types": "^0.14.2",
34+
"@lifeart/ember-extract-inline-templates": "2.2.0",
3135
"dag-map": "^2.0.2",
3236
"ember-meta-explorer": "1.2.0",
33-
"ember-template-recast": "^5.0.3",
37+
"ember-template-recast": "^6.1.3",
3438
"find-up": "^5.0.0",
3539
"flat": "^5.0.2",
3640
"fuzzaldrin": "^2.1.0",
3741
"json-parse-ast": "^1.0.8",
38-
"lodash": "^4.17.20",
42+
"lodash": "^4.17.21",
3943
"memoizee": "^0.4.15",
4044
"picomatch": "^2.3.0",
4145
"semver": "^7.3.5",
@@ -56,7 +60,7 @@
5660
"@types/flat": "^5.0.2",
5761
"@types/fuzzaldrin": "^2.1.3",
5862
"@types/jest": "^26.0.20",
59-
"@types/lodash": "^4.14.167",
63+
"@types/lodash": "^4.14.178",
6064
"@types/memoizee": "^0.4.5",
6165
"@types/node": "^12.12.5",
6266
"@types/picomatch": "^2.3.0",
@@ -81,8 +85,9 @@
8185
"ts-jest": "^26.5.6",
8286
"ts-loader": "^9.2.3",
8387
"ts-node": "^8.10.2",
84-
"typescript": "^4.1.3",
88+
"typescript": "^4.5.5",
8589
"webpack": "^5.44.0",
90+
"webpack-bundle-analyzer": "^4.5.0",
8691
"webpack-cli": "^4.7.2"
8792
},
8893
"lint-staged": {
@@ -108,7 +113,8 @@
108113
"test": "jest",
109114
"test:coverage": "rimraf inst/ && nyc instrument lib inst && nyc --no-clean --reporter=clover --reporter=json --reporter=lcov yarn run jest --no-coverage",
110115
"watch": "tsc --watch -p .",
111-
"prepare": "husky install"
116+
"prepare": "husky install",
117+
"test:worker-bundle": "npx http-server ."
112118
},
113119
"volta": {
114120
"node": "14.19.0",

src/builtin-addons/core/script-completion-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as memoize from 'memoizee';
44
import { logError, logInfo, logDebugInfo } from '../../utils/logger';
55
import Server from '../../server';
66
import { Project } from '../../project';
7-
import * as t from '@babel/types';
7+
import type * as t from '@babel/types';
88
import {
99
isStoreModelLookup,
1010
isRouteLookup,

src/builtin-addons/core/script-definition-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import * as t from '@babel/types';
2+
import type * as t from '@babel/types';
33
import { Definition, Location } from 'vscode-languageserver/node';
44
import { DefinitionFunctionParams } from './../../utils/addon-api';
55
import { pathsToLocations, getAddonPathsForType, getAddonImport } from '../../utils/definition-helpers';

src/builtin-addons/core/template-completion-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CompletionItem, CompletionItemKind } from 'vscode-languageserver/node';
22
import { AddonMeta, CompletionFunctionParams } from './../../utils/addon-api';
3-
import { uniqBy } from 'lodash';
3+
// @ts-expect-error esmodule
4+
import * as uniqBy from 'lodash/uniqBy';
45

56
import * as memoize from 'memoizee';
67
import { emberBlockItems, emberMustacheItems, emberSubExpressionItems, emberModifierItems } from './ember-helpers';
@@ -42,7 +43,6 @@ import {
4243

4344
import { normalizeToAngleBracketComponent } from '../../utils/normalizers';
4445
import { getTemplateBlocks } from '../../utils/template-tokens-collector';
45-
import type { ASTNode } from 'ast-types';
4646
import { ASTv1 } from '@glimmer/syntax';
4747
import { URI } from 'vscode-uri';
4848
import { componentsContextData } from './template-context-provider';
@@ -345,7 +345,7 @@ export default class TemplateCompletionProvider {
345345

346346
return scopedValues;
347347
}
348-
async getParentComponentYields(focusPath: ASTNode & { tag: string }) {
348+
async getParentComponentYields(focusPath: any) {
349349
if (focusPath.type !== 'ElementNode') {
350350
return [];
351351
}

src/builtin-addons/core/template-context-provider.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { CompletionItemKind } from 'vscode-languageserver';
22
import type { CompletionItem } from 'vscode-languageserver';
3-
43
import { logDebugInfo, logError } from '../../utils/logger';
5-
64
import { extractComponentInformationFromMeta, IComponentMetaInformation, IJsMeta, processJSFile, processTemplate } from 'ember-meta-explorer';
7-
8-
import { uniqBy } from 'lodash';
5+
// @ts-expect-error esmodule
6+
import * as uniqBy from 'lodash/uniqBy';
97
import FSProvider from '../../fs-provider';
108
import { asyncFilter } from '../../utils/layout-helpers';
119

src/completion-provider/script-completion-provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import ASTPath from '../glimmer-utils';
55
import { toPosition } from '../estree-utils';
66
import { filter } from 'fuzzaldrin';
77
import { parseScriptFile as parse } from 'ember-meta-explorer';
8-
import { uniqBy } from 'lodash';
8+
// @ts-expect-error esmodule
9+
import * as uniqBy from 'lodash/uniqBy';
910
import { getExtension } from '../utils/file-extension';
1011
import { logDebugInfo } from '../utils/logger';
1112
import GlimmerScriptCompletionProvider from './glimmer-script-completion-provider';

src/server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ import { Usage, findRelatedFiles, waitForTokensToBeCollected, getAllTemplateToke
6060
import { URI } from 'vscode-uri';
6161
import { MatchResultType } from './utils/path-matcher';
6262
import { FileChangeType } from 'vscode-languageserver/node';
63-
import { debounce } from 'lodash';
63+
// @ts-expect-error esmodule
64+
import * as debounce from 'lodash/debounce';
6465
import { Config, Initializer } from './types';
6566
import { asyncGetJSON, isFileBelongsToRoots, mGetProjectAddonsInfo, setRequireSupport, setSyncFSSupport } from './utils/layout-helpers';
6667
import FSProvider, { AsyncFsProvider, setFSImplementation } from './fs-provider';
@@ -368,6 +369,10 @@ export default class Server {
368369
throw new Error('uELS constructor accept connection instance as first argument');
369370
}
370371

372+
if (globalThis.process) {
373+
globalThis.process.title = 'unstable_ember_language_server';
374+
}
375+
371376
this.options = { ...defaultServerOptions, ...options };
372377
this.connection = connection;
373378
this.fs = this.options.fs === 'sync' ? new FSProvider() : new AsyncFsProvider(this);

src/symbols/js-document-symbol-provider.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { parseScriptFile as parse } from 'ember-meta-explorer';
33
import DocumentSymbolProvider from './document-symbol-provider';
44
import { toLSRange } from '../estree-utils';
55
import { logDebugInfo } from '../utils/logger';
6-
import { visit } from 'ast-types';
6+
import traverse from '@babel/traverse';
77

88
export default class JSDocumentSymbolProvider implements DocumentSymbolProvider {
99
extensions: string[] = ['.js'];
@@ -14,15 +14,13 @@ export default class JSDocumentSymbolProvider implements DocumentSymbolProvider
1414
try {
1515
const ast = parse(content);
1616

17-
visit(ast, {
18-
visitProperty(path: any) {
17+
traverse(ast, {
18+
Property(path: any) {
1919
const node = path.node;
2020

2121
const symbol = SymbolInformation.create(node.key.name, SymbolKind.Property, toLSRange(node.key.loc));
2222

2323
symbols.push(symbol);
24-
25-
this.traverse(path);
2624
},
2725
});
2826
} catch (e) {

src/utils/glimmer-script.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
import { getTemplateLocals, preprocess, ASTv1 } from '@glimmer/syntax';
22
import { Range as LSRange } from 'vscode-languageserver/node';
33
import { parseScriptFile as parse } from 'ember-meta-explorer';
4-
import { visit } from 'ast-types';
4+
import traverse from '@babel/traverse';
55

66
interface IBabelScope {
7-
getBindings(): Record<string, unknown>;
7+
bindings: Record<string, unknown>;
88
parent?: IBabelScope;
99
}
1010

1111
export function getPlaceholderPathFromAst(ast: any, key: string): null | { scope: IBabelScope } {
1212
let keyPath = null;
1313

14-
visit(ast, {
15-
visitIdentifier(path: {
16-
node: { name: string };
17-
scope: {
18-
bindings: Record<string, unknown>;
19-
};
20-
}) {
14+
traverse(ast, {
15+
Identifier(path) {
2116
const node = path.node;
2217

2318
if (node.name === key) {
2419
keyPath = path;
2520

21+
path.stop();
22+
2623
return false;
2724
}
28-
29-
this.traverse(path);
3025
},
3126
});
3227

@@ -47,7 +42,7 @@ export function getScope(scope: IBabelScope): string[] {
4742
let resolvedScope: undefined | IBabelScope = scope;
4843

4944
while (resolvedScope) {
50-
for (const binding in scope.getBindings()) {
45+
for (const binding in resolvedScope.bindings) {
5146
names.add(binding);
5247
}
5348

0 commit comments

Comments
 (0)