Skip to content

Commit 2bab955

Browse files
shlokaminmjhuffb-cooperkojijerader
authored
chore(monorepo): migrate frontend bundling from webpack to vite (#14405)
migrate frontend bundler from webpack to vite Co-authored-by: Jamey Huffnagle <[email protected]> Co-authored-by: Brian Cooper <[email protected]> Co-authored-by: koji <[email protected]> Co-authored-by: Jethary <[email protected]> Co-authored-by: ncdiehl11 <[email protected]> Co-authored-by: smb2268 <[email protected]> Co-authored-by: Brent Hagen <[email protected]>
1 parent 9bbcc02 commit 2bab955

File tree

1,824 files changed

+56898
-34053
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,824 files changed

+56898
-34053
lines changed

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
**/venv/**
77
.opentrons_config
88
**/tsconfig*.json
9-
9+
**/vite.config.ts
1010
# prettier
1111
**/package.json
1212
**/CHANGELOG.md
13-
lerna.json
1413
!api/release-notes.md
1514
!app-shell/build/release-notes.md
1615

.eslintrc.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
'plugin:react/recommended',
1313
'prettier',
1414
'plugin:json/recommended',
15+
'plugin:storybook/recommended',
1516
],
1617

1718
plugins: ['react', 'react-hooks', 'json', 'jest', 'testing-library'],
@@ -89,6 +90,11 @@ module.exports = {
8990
'@typescript-eslint/unbound-method': 'warn',
9091
'@typescript-eslint/consistent-generic-constructors': 'warn',
9192
'@typescript-eslint/no-misused-promises': 'warn',
93+
// need this to be able to pass in css prop into raw elements (babel adds this at build time for styled-components)
94+
'react/no-unknown-property': [
95+
'error',
96+
{ ignore: ['css', 'indeterminate'] },
97+
],
9298
},
9399
},
94100
{
@@ -98,6 +104,7 @@ module.exports = {
98104
'**/__mocks__/**.@(js|ts|tsx)',
99105
'**/__utils__/**.@(js|ts|tsx)',
100106
'**/__fixtures__/**.@(js|ts|tsx)',
107+
'**/fixtures/**.@(js|ts|tsx)',
101108
'scripts/*.@(js|ts|tsx)',
102109
],
103110
env: {
@@ -108,7 +115,7 @@ module.exports = {
108115
'jest/expect-expect': 'off',
109116
'jest/no-standalone-expect': 'off',
110117
'jest/no-disabled-tests': 'error',
111-
'jest/consistent-test-it': 'error',
118+
'jest/consistent-test-it': ['error', { fn: 'it' }],
112119
'@typescript-eslint/consistent-type-assertions': 'off',
113120
'@typescript-eslint/no-var-requires': 'off',
114121
'@typescript-eslint/explicit-function-return-type': 'off',
@@ -127,6 +134,7 @@ module.exports = {
127134
env: { jest: true },
128135
extends: ['plugin:testing-library/react'],
129136
rules: {
137+
'testing-library/no-manual-cleanup': 'off',
130138
'testing-library/prefer-screen-queries': 'warn',
131139
},
132140
},
@@ -140,6 +148,9 @@ module.exports = {
140148
{
141149
files: ['**/cypress/**'],
142150
extends: ['plugin:cypress/recommended'],
151+
rules: {
152+
'cypress/unsafe-to-chain-command': 'warn',
153+
},
143154
},
144155
],
145156
}

.github/workflows/app-test-build-deploy.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
- 'app-shell-odd/**/*'
1212
- 'components/**/*'
1313
- 'shared-data/**/*'
14-
- 'webpack-config/**/*'
1514
- 'discovery-client/**/*'
1615
- '*.js'
1716
- 'scripts/**/*'
@@ -32,7 +31,6 @@ on:
3231
- 'app-shell-odd/**/*'
3332
- 'components/**/*'
3433
- 'shared-data/**/*'
35-
- 'webpack-config/**/*'
3634
- 'discovery-client/**/*'
3735
- '*.js'
3836
- '*.json'
@@ -141,7 +139,7 @@ jobs:
141139
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache
142140
make setup-js
143141
- name: 'test native(er) packages'
144-
run: make test-js-internal tests="app-shell/src app-shell-odd/src discovery-client/src" cov_opts="--coverage=true --ci=true --collectCoverageFrom='(app-shell|app-shell-odd| discovery-client)/src/**/*.(js|ts|tsx)'"
142+
run: make test-js-internal tests="app-shell/src app-shell-odd/src discovery-client/src" cov_opts="--coverage=true"
145143
- name: 'Upload coverage report'
146144
uses: 'codecov/codecov-action@v3'
147145
with:
@@ -293,7 +291,7 @@ jobs:
293291
OT_APP_DEPLOY_FOLDER: ${{ steps.project.outputs.folder }}
294292

295293
run: |
296-
make -C app-shell dist-${{ matrix.os }}
294+
make -C app-shell dist-${{ matrix.os }} USE_HARD_LINKS=false
297295
298296
- name: 'upload github artifact'
299297
if: matrix.target == 'desktop'
@@ -443,7 +441,6 @@ jobs:
443441
path: |
444442
${{ github.workspace }}/.npm-cache/_prebuild
445443
${{ github.workspace }}/.yarn-cache
446-
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
447444
- name: 'setup-js'
448445
run: |
449446
npm config set cache ${{ github.workspace }}/.npm-cache

.github/workflows/components-test-build-deploy.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ on:
88
- 'Makefile'
99
- 'components/**'
1010
- 'app/**/*.stories.@(js|jsx|ts|tsx)'
11-
- 'webpack-config/**'
1211
- 'package.json'
1312
- '.github/workflows/components-test-build-deploy.yaml'
1413
push:
1514
paths:
1615
- 'components/**'
1716
- 'app/**/*.stories.@(js|jsx|ts|tsx)'
18-
- 'webpack-config/**'
1917
- 'package.json'
2018
- '.github/workflows/components-test-build-deploy.yaml'
2119
branches:
@@ -59,7 +57,6 @@ jobs:
5957
- name: 'setup-js'
6058
run: |
6159
npm config set cache ./.npm-cache
62-
yarn config set cache-folder ./.yarn-cache
6360
make setup-js
6461
- name: 'run components unit tests'
6562
run: make -C components test-cov
@@ -177,21 +174,10 @@ jobs:
177174
with:
178175
node-version: '18.19.0'
179176
registry-url: 'https://registry.npmjs.org'
180-
- name: 'cache yarn cache'
181-
uses: actions/cache@v3
182-
with:
183-
path: |
184-
${{ github.workspace }}/.yarn-cache
185-
${{ github.workspace }}/.npm-cache
186-
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
187-
restore-keys: |
188-
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-
189177
- name: 'setup-js'
190178
run: |
191179
npm config set cache ./.npm-cache
192180
yarn config set cache-folder ./.yarn-cache
193-
yarn config set network-timeout 60000
194-
yarn
195181
- name: 'build typescript'
196182
run: make build-ts
197183
- name: 'build library'

.github/workflows/js-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ jobs:
8888
if: always() && steps.setup-js.outcome == 'success'
8989
run: make lint-css
9090
- name: 'test scripts'
91-
run: yarn jest scripts
91+
run: yarn vitest scripts

.github/workflows/ll-test-build-deploy.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
- 'labware-library/**'
99
- 'shared-data/labware/**'
1010
- 'components/**'
11-
- 'webpack-config/**'
1211
- 'package.json'
1312
- '.github/workflows/ll-test-build-deploy.yaml'
1413
- '.github/actions/webstack/deploy-to-sandbox/**'
@@ -18,7 +17,6 @@ on:
1817
- 'labware-library/**'
1918
- 'shared-data/labware/**'
2019
- 'components/**'
21-
- 'webpack-config/**'
2220
- 'package.json'
2321
- '.github/workflows/ll-test-build-deploy.yaml'
2422
branches:

.github/workflows/pd-test-build-deploy.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
- 'step-generation/**'
1010
- 'shared-data/**'
1111
- 'components/**'
12-
- 'webpack-config/**'
1312
- 'package.json'
1413
- '.github/workflows/pd-test-build-deploy.yaml'
1514
push:
@@ -18,7 +17,6 @@ on:
1817
- 'step-generation/**'
1918
- 'shared-data/**'
2019
- 'components/**'
21-
- 'webpack-config/**'
2220
- 'package.json'
2321
- '.github/workflows/pd-test-build-deploy.yaml'
2422
branches:
@@ -145,8 +143,6 @@ jobs:
145143
${{ github.workspace }}/.yarn-cache
146144
${{ github.workspace }}/.npm-cache
147145
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
148-
restore-keys: |
149-
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-
150146
- name: 'setup-js'
151147
run: |
152148
npm config set cache ./.npm-cache

.github/workflows/shared-data-test-lint-deploy.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ jobs:
237237
- name: 'js deps'
238238
run: |
239239
npm config set cache ./.npm-cache
240-
yarn config set cache-folder ./.yarn-cache
241-
yarn config set network-timeout 60000
242-
yarn
240+
yarn config set cache-folder ./.yarn-cache
243241
- name: 'build typescript'
244242
run: make build-ts
245243
- name: 'build library'

.github/workflows/step-generation-test.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ on:
77
paths:
88
- 'step-generation/**'
99
- 'shared-data/**'
10-
- 'webpack-config/**'
1110
- 'package.json'
1211
- '.github/workflows/step-generation-test.yaml'
1312
push:
1413
paths:
1514
- 'step-generation/**'
1615
- 'shared-data/**'
17-
- 'webpack-config/**'
1816
- 'package.json'
1917
- '.github/workflows/step-generation-test.yaml'
2018
branches:

.github/workflows/tag-releases.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
npm config set cache ${{ github.workspace }}/.npm-cache
3838
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache
3939
yarn install
40+
4041
- name: 'create release'
4142
run: |
4243
node ./scripts/deploy/create-release.js ${{ github.token }} ${{ github.ref_name }} --deploy

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,4 @@ opentrons-robot-app.tar.gz
159159

160160
# asdf versions file
161161
.tool-versions
162+
mock_dir

.npmrc

Whitespace-only changes.

.storybook/main.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
'use strict'
2-
3-
const { baseConfig } = require('@opentrons/webpack-config')
4-
51
module.exports = {
6-
webpackFinal: config => ({
7-
...config,
8-
module: { ...config.module, rules: baseConfig.module.rules },
9-
plugins: [...config.plugins, ...baseConfig.plugins],
10-
}),
112
stories: [
123
'../components/**/*.stories.@(js|jsx|ts|tsx)',
134
'../app/**/*.stories.@(js|jsx|ts|tsx)',
145
],
6+
157
addons: [
168
'@storybook/addon-links',
179
'@storybook/addon-essentials',
1810
'storybook-addon-pseudo-states',
1911
],
12+
13+
framework: {
14+
name: '@storybook/react-vite',
15+
options: {},
16+
},
17+
18+
docs: {
19+
autodocs: true,
20+
},
2021
}
File renamed without changes.

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ See [DEV_SETUP.md](./DEV_SETUP.md) for our recommended development setup guides
171171
We use:
172172

173173
- [pytest][] to test Python
174-
- [Jest][jest] to test JavaScript
174+
- [Vitest][vitest] to test JavaScript
175175
- To run tests in watch mode, you should also install [watchman][]
176176
- [Cypress.io][cypress] for end to end UI testing
177177

@@ -199,7 +199,7 @@ make test-js watch=true
199199
make test-js cover=false
200200

201201
# update snapshot tests
202-
# https://jestjs.io/docs/en/snapshot-testing
202+
# https://vitest.dev/guide/snapshot.html
203203
make test-js updateSnapshot=true
204204
```
205205

@@ -217,7 +217,7 @@ make check-js
217217
```
218218

219219
[pytest]: https://docs.pytest.org/en/latest/
220-
[jest]: https://jestjs.io/
220+
[vitest]: https://vitest.dev/
221221
[watchman]: https://facebook.github.io/watchman/
222222
[cypress]: https://www.cypress.io/
223223

DEV_SETUP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ eval "$(pyenv init -)"
148148
# ...
149149
```
150150

151-
#### 3. Install `jpeg` if on ARM Mac (M1)
151+
#### 3. Install `jpeg` if on ARM Mac (M1/M2/M3)
152152

153153
`/hardware` depends on the Python library Pillow. On ARM Macs, `pip` will build Pillow from source, which requires [jpeg](https://formulae.brew.sh/formula/jpeg) to be installed.
154154

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ endif
4747

4848
# run at usage (=), not on makefile parse (:=)
4949
# todo(mm, 2021-03-17): Deduplicate with scripts/python.mk.
50-
usb_host=$(shell yarn run -s discovery find -i 169.254)
50+
usb_host=$(shell yarn -s discovery find -i 169.254)
5151

5252
# install all project dependencies
5353
.PHONY: setup
@@ -62,6 +62,7 @@ setup-py-toolchain:
6262

6363
# front-end dependecies handled by yarn
6464
.PHONY: setup-js
65+
setup-js:
6566
setup-js: setup-py-toolchain
6667
yarn config set network-timeout 60000
6768
yarn
@@ -263,7 +264,7 @@ circular-dependencies-js:
263264

264265
.PHONY: test-js-internal
265266
test-js-internal:
266-
yarn jest $(tests) $(test_opts) $(cov_opts)
267+
yarn vitest $(tests) $(test_opts) $(cov_opts)
267268

268269
.PHONY: test-js-%
269270
test-js-%:

__mocks__/electron-store.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
// mock electron-store
22
'use strict'
3+
import { vi } from 'vitest'
4+
import { DEFAULTS_V12, migrate } from '../app-shell-odd/src/config/migrate'
35

4-
module.exports = jest.createMockFromModule(
5-
'../app-shell/node_modules/electron-store'
6-
)
6+
// will by default mock the config dir. if you need other behaavior you can
7+
// override this mock (see app-shell/src/__tests__/discovery.test.ts for an example)
8+
const Store = vi.fn(function () {
9+
this.store = vi.fn(() => {
10+
return {}
11+
})
12+
this.get = vi.fn(property => {
13+
return {}
14+
})
15+
this.onDidChange = vi.fn()
16+
})
17+
18+
// eslint-disable-next-line import/no-default-export
19+
export default Store
20+
21+
// const Store = vi.fn(function () {
22+
// this.store = vi.fn(() => migrate(DEFAULTS_V12))
23+
// this.get = vi.fn(property => {
24+
// return this.store()[property]
25+
// })
26+
// this.onDidChange = vi.fn()
27+
// })

__mocks__/electron-updater.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// mock electron-updater
22
'use strict'
3-
3+
import { vi } from 'vitest'
44
const EventEmitter = require('events')
55
const autoUpdater = new EventEmitter()
66

@@ -13,12 +13,12 @@ module.exports.__mockReset = () => {
1313
currentVersion: { version: '0.0.0-mock' },
1414
channel: null,
1515

16-
checkForUpdates: jest.fn(),
17-
checkForUpdatesAndNotify: jest.fn(),
18-
downloadUpdate: jest.fn(),
19-
getFeedURL: jest.fn(),
20-
setFeedURL: jest.fn(),
21-
quitAndInstall: jest.fn(),
16+
checkForUpdates: vi.fn(),
17+
checkForUpdatesAndNotify: vi.fn(),
18+
downloadUpdate: vi.fn(),
19+
getFeedURL: vi.fn(),
20+
setFeedURL: vi.fn(),
21+
quitAndInstall: vi.fn(),
2222
})
2323
}
2424

0 commit comments

Comments
 (0)