Skip to content

Commit

Permalink
Avoid loading full lodash (#10308)
Browse files Browse the repository at this point in the history
* Avoid loading full lodash.

* esModuleInterop

* Revert "esModuleInterop"

This reverts commit f3ebb12.

* force require for modules no default export

* Use direct import in webview.
  • Loading branch information
rebornix authored Jun 4, 2022
1 parent a5d77fb commit ca8090c
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ module.exports = {
],
'react/jsx-uses-vars': 'error',
'react/jsx-uses-react': 'error',
'no-restricted-imports': ['error', { "paths": ["lodash"] }],
'import/no-restricted-paths': [
'error',
{
Expand Down
3 changes: 2 additions & 1 deletion src/kernels/jupyter/preferredRemoteKernelIdProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Licensed under the MIT License.

import { inject, injectable, named } from 'inversify';
import { cloneDeep } from 'lodash';
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-require-imports */
import cloneDeep = require('lodash/cloneDeep');
import { Memento, Uri } from 'vscode';
import { traceInfo, traceVerbose } from '../../platform/logging';
import { getDisplayPath } from '../../platform/common/platform/fs-paths';
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/jupyter/serverSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { inject, injectable } from 'inversify';
import { isNil } from 'lodash';
import isNil = require('lodash/isNil');
import { EventEmitter, QuickPickItem, ThemeIcon, Uri } from 'vscode';
import { IApplicationShell, IClipboard } from '../../platform/common/application/types';
import { traceDecoratorError, traceError, traceWarning } from '../../platform/logging';
Expand Down
2 changes: 1 addition & 1 deletion src/notebooks/controllers/remoteSwitcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import { noop } from 'lodash';
import noop = require('lodash/noop');
import { StatusBarAlignment, StatusBarItem } from 'vscode';
import { IExtensionSingleActivationService } from '../../platform/activation/types';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/notebooks/execution/notebookUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { noop } from 'lodash';
import noop = require('lodash/noop');
import { isPromise } from 'rxjs/internal-compatibility';
import { NotebookDocument, NotebookEditor, workspace, WorkspaceEdit, window } from 'vscode';
import { createDeferred } from '../../platform/common/utils/async';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from 'chai';
import { cloneDeep } from 'lodash';
import cloneDeep = require('lodash/cloneDeep');
import * as sinon from 'sinon';
import * as path from '../../../platform/vscode-path/path';
import * as vscode from 'vscode';
Expand Down
2 changes: 1 addition & 1 deletion src/test/datascience/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as vscode from 'vscode';
import { getFilePath } from '../../platform/common/platform/fs-paths';
import { traceInfo } from '../../platform/logging';
import { noop } from 'lodash';
import noop = require('lodash/noop');
import { IPythonApiProvider } from '../../platform/api/types';
import { IJupyterSettings, Resource } from '../../platform/common/types';
import { InteractiveWindow } from '../../interactive-window/interactiveWindow';
Expand Down
2 changes: 1 addition & 1 deletion src/test/datascience/mockCommandManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { noop } from 'lodash';
import noop = require('lodash/noop');
import { Disposable, TextEditor, TextEditorEdit } from 'vscode';

import { ICommandNameArgumentTypeMapping } from '../../platform/common/application/commands';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { inject, injectable } from 'inversify';

import { captureTelemetry } from '../../../telemetry';
import { IDataViewer, IDataViewerDataProvider, IDataViewerFactory } from './types';
import { debounce } from 'lodash';
import debounce = require('lodash/debounce');
import { ICommandManager } from '../../../platform/common/application/types';
import { ContextKey } from '../../../platform/common/contextKey';
import { IAsyncDisposable, IAsyncDisposableRegistry, IDisposableRegistry } from '../../../platform/common/types';
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/webview-side/data-explorer/mainPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { generateTestData } from './testData';
import '../react-common/codicon/codicon.css';
import '../react-common/seti/seti.less';
import { SliceControl } from './sliceControl';
import { debounce } from 'lodash';
import debounce from 'lodash/debounce';
import * as uuid from 'uuid/v4';

import { initializeIcons } from '@fluentui/react';
Expand Down

0 comments on commit ca8090c

Please sign in to comment.