Skip to content

Commit

Permalink
feat: reduce size of apix bundle (#676)
Browse files Browse the repository at this point in the history
1. all package builds now generate es modules.
2. functions from lodash now imported in the format `import pick from 'lodash/pick'`
  • Loading branch information
bryans99 authored May 11, 2021
1 parent eb1a427 commit 0d74f6a
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 22 deletions.
4 changes: 3 additions & 1 deletion packages/api-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "@looker/api-explorer",
"version": "0.9.7",
"description": "Looker API Explorer",
"main": "lib/esm/index.js",
"main": "lib/index.js",
"module": "lib/esm/index.js",
"sideEffects": "false",
"typings": "lib/index.d.ts",
"license": "MIT",
"author": "Looker",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/components/DocSDKs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import { IMethod } from '@looker/sdk-codegen'
import { clone } from 'lodash'
import clone from 'lodash/clone'

/**
* Given a method create a copy and remove its description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
import React from 'react'
import { ApiModel, CriteriaToSet } from '@looker/sdk-codegen'
import { pick } from 'lodash'
import pick from 'lodash/pick'
import userEvent from '@testing-library/user-event'
import { act, screen, waitFor } from '@testing-library/react'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import React from 'react'
import { pick } from 'lodash'
import pick from 'lodash/pick'
import userEvent from '@testing-library/user-event'
import { screen } from '@testing-library/react'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import React from 'react'
import { pick } from 'lodash'
import pick from 'lodash/pick'
import { screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'

Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/reducers/spec/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import { ApiModel, SpecList } from '@looker/sdk-codegen'
import { omit } from 'lodash'
import omit from 'lodash/omit'

import { specs } from '../../test-data'
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/scenes/DiffScene/diffUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

import { cloneDeep } from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import {
compareSpecs,
DiffFilter,
Expand Down
6 changes: 4 additions & 2 deletions packages/code-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "@looker/code-editor",
"version": "0.1.1",
"description": "A syntax highlighter Viewer and Editor for Looker SDK supported languages.",
"main": "lib/esm/index.js",
"main": "lib/index.js",
"module": "lib/esm/index.js",
"sideEffects": "false",
"typings": "lib/index.d.ts",
"files": [
"lib"
Expand All @@ -24,7 +26,7 @@
"watch": "yarn lerna exec --scope @looker/code-editor --stream 'BABEL_ENV=build babel src --root-mode upward --out-dir lib/esm --source-maps --extensions .ts,.tsx --no-comments --watch'"
},
"devDependencies": {
"@looker/components-test-utils": "^1.1.3",
"@looker/components-test-utils": "^1.1.3",
"@looker/sdk-codegen": "^21.0.16",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
Expand Down
6 changes: 2 additions & 4 deletions packages/extension-api-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
"name": "@looker/extension-api-explorer",
"version": "21.6.0",
"description": "Looker API Explorer extension version ",
"main": "lib/index.js",
"module": "lib/esm/index.js",
"sideEffects": "false",
"typings": "lib/index.d.ts",
"main": "dist/bundle.js",
"sideEffects": false,
"license": "MIT",
"private": true,
"homepage": "https://github.com/looker-open-source/sdk-codegen/tree/main/packages/extension-api-explorer",
Expand Down
3 changes: 3 additions & 0 deletions packages/extension-api-explorer/webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ const browser = require('../../webpack.browser.config')()

module.exports = merge(base, browser, {
mode: 'production',
optimization: {
chunkIds: 'named',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import React, { useEffect } from 'react'
import { useLocation, useHistory } from 'react-router-dom'
import { ExtensionHostApi } from '@looker/extension-sdk'
import { clone } from 'lodash'
import clone from 'lodash/clone'
import { RouteChangeListenerProps } from './types'

export const RouteChangeListener: React.FC<RouteChangeListenerProps> = ({
Expand Down
2 changes: 1 addition & 1 deletion packages/hackathon/src/data/sheets_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SOFTWARE.
*/
import { omit } from 'lodash'
import omit from 'lodash/omit'
import { ValidationMessages } from '@looker/components'
import { DefaultSettings } from '@looker/sdk-rtl'
import { ITabTable, SheetSDK } from '@looker/wholly-sheet'
Expand Down
4 changes: 3 additions & 1 deletion packages/run-it/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "@looker/run-it",
"version": "0.9.7",
"description": "A dynamic REST request input form and response visualizer",
"main": "lib/esm/index.js",
"main": "lib/index.js",
"module": "lib/esm/index.js",
"sideEffects": "false",
"typings": "lib/index.d.ts",
"files": [
"lib"
Expand Down
2 changes: 1 addition & 1 deletion packages/run-it/src/utils/requestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

import { IAPIMethods, IRawResponse } from '@looker/sdk-rtl'
import { cloneDeep } from 'lodash'
import cloneDeep from 'lodash/cloneDeep'

import { RunItHttpMethod, RunItInput, RunItValues } from '../RunIt'
import { runItSDK } from './RunItSDK'
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk-codegen-scripts/src/convert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
*/

import { readFileSync } from 'fs'
import { cloneDeep, isEmpty } from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import isEmpty from 'lodash/isEmpty'
import { NodeSettingsIniFile, LookerNodeSDK } from '@looker/sdk-node'
import {
fixConversion,
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk-codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"version": "21.0.16",
"description": "Looker SDK Codegen core",
"main": "lib/index.js",
"module": "lib/esm/index.js",
"sideEffects": "false",
"typings": "lib/index.d.ts",
"files": [
"lib"
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-codegen/src/sdkModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ export class Method extends SchemadSymbol implements IMethod {
}

get errorResponses() {
// TODO use lodash or underscore?
// TODO use lodash?
const result = []
const map = new Map()
for (const item of this.responses.filter((r) => r.statusCode >= 400)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-codegen/src/specConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

import { isEmpty } from 'lodash'
import isEmpty from 'lodash/isEmpty'
import { APIMethods, Url } from '@looker/sdk-rtl'
import { ApiModel, ArgValues, IApiModel, KeyedCollection } from './sdkModels'

Expand Down
3 changes: 2 additions & 1 deletion packages/sdk-codegen/src/specDiff.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
*/

import { readFileSync } from 'fs'
import { cloneDeep, pick } from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import pick from 'lodash/pick'
import { OperationObject } from 'openapi3-ts'

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/wholly-sheet/src/RowModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import { v4 as uuidv4 } from 'uuid'
import { boolDefault } from '@looker/sdk-rtl'
import { omit } from 'lodash'
import omit from 'lodash/omit'
import { SheetValues } from './SheetSDK'

export const noDate = new Date(-8640000000000000)
Expand Down

0 comments on commit 0d74f6a

Please sign in to comment.