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

feat!: Webpack/Jest to Vite/Vitest migration #2716

Merged
merged 40 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a6c80ff
chore(react): upgrade to 18
jpandersen87 Jan 18, 2024
b008312
Merge branch 'main' into react-18
jpandersen87 Jan 18, 2024
260eadf
match webpack output plus more
jpandersen87 Jan 19, 2024
6e56622
migrate jest to vitest
jpandersen87 Jan 19, 2024
6ee0620
refresh yarn.lock, fix configs, fix tests
jpandersen87 Jan 20, 2024
b737ffd
first pass storybook webpack to vite
jpandersen87 Jan 21, 2024
a9e04fd
dependency updates, sb config fixes
jpandersen87 Jan 21, 2024
fd11498
update github workflows
jpandersen87 Jan 21, 2024
a67a0b9
remove args from test:coverage in build-and-test
jpandersen87 Jan 21, 2024
e06aa28
fix eof
jpandersen87 Feb 1, 2024
e47ccec
Merge branch 'main' into react-18
jpandersen87 Feb 1, 2024
1c4a2c9
use ReactNode
jpandersen87 Feb 1, 2024
cffed19
Merge branch 'react-18' into vite
jpandersen87 Feb 2, 2024
4d9e4b3
remove unneeded tabbable mock
jpandersen87 Feb 2, 2024
adbc25d
husky added for git hooks
jpandersen87 Feb 2, 2024
729df12
update happo config to esm syntax
jpandersen87 Feb 2, 2024
290c0ba
add vitest linting, fix lint warn/err
jpandersen87 Feb 2, 2024
fd32f3d
fix tests
jpandersen87 Feb 2, 2024
e1931c2
cleanup vite config
jpandersen87 Feb 3, 2024
2f2ed1e
experimental fix for danger errors on push
jpandersen87 Feb 3, 2024
7c5d6bf
Merge branch 'main' into vite
jpandersen87 Feb 3, 2024
2872cf8
merge fixes
jpandersen87 Feb 3, 2024
2b8b7e8
fix package type, update all deps
jpandersen87 Feb 3, 2024
f01f417
fix serversidetest
jpandersen87 Feb 3, 2024
03cdc59
Revert "update happo config to esm syntax"
jpandersen87 Feb 3, 2024
6dcc376
rename happo to cjs
jpandersen87 Feb 3, 2024
61863f7
bring webpack/babel-loader back for happo
jpandersen87 Feb 3, 2024
1e82459
manually point to happo config
jpandersen87 Feb 3, 2024
2b49b4a
continued happo troubleshooting
jpandersen87 Feb 3, 2024
c721823
update deps, fix uswds img imports
jpandersen87 Feb 5, 2024
1fe2374
add bundles test, fix test warnings
jpandersen87 Feb 5, 2024
2918dc2
Merge branch 'main' into vite
jpandersen87 Feb 5, 2024
199de2f
post-merge lockfile
jpandersen87 Feb 5, 2024
b5b0ec9
fix test with race condition
jpandersen87 Feb 5, 2024
92be343
config cleanup
jpandersen87 Feb 5, 2024
33f9a42
update deps, fix lint warn/err, fix formatting
jpandersen87 Feb 5, 2024
2ed071f
fix coverage error due to yarn.lock
jpandersen87 Feb 5, 2024
fc1545f
Merge branch 'main' into vite, declare yarn v1
jpandersen87 Feb 13, 2024
dce3ae8
Merge branch 'main' into vite
jpandersen87 Mar 4, 2024
ad1f4fa
Merge branch 'main' into vite
brandonlenz Mar 5, 2024
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: 0 additions & 1 deletion .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Supported browsers
> 2%
last 2 versions
IE 11
not dead
24 changes: 13 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"parser": "@babel/eslint-parser",
"root": true,
"plugins": [
"import",
"@typescript-eslint",
"jsx-a11y",
"react",
"react-hooks",
"no-only-tests",
"security"
"security",
"vitest"
],
"env": {
"browser": true,
Expand All @@ -21,16 +22,12 @@
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"requireConfigFile": false
},
"settings": {
"react": {
"version": "detect"
},
"import/resolver": {
"webpack": {
"config": "./webpack.config.js"
}
}
},
"overrides": [
Expand All @@ -53,7 +50,10 @@
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier"
]
],
"rules": {
"import/no-unresolved": "off"
}
}
],
"extends": [
Expand All @@ -63,8 +63,10 @@
"plugin:import/typescript",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"prettier",
"plugin:security/recommended-legacy"
"plugin:security/recommended-legacy",
"plugin:storybook/recommended",
"plugin:vitest/recommended",
"prettier"
],
"rules": {
"no-only-tests/no-only-tests": "error",
Expand Down
6 changes: 0 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,4 @@ updates:
- dependency-name: '@types/react-dom'
versions:
- '>=18.0.0'
- dependency-name: '@storybook/react'
versions:
- '>=7.0.0'
- dependency-name: '@storybook/addon-essentials'
versions:
- '>=7.0.0'
- dependency-name: 'uswds'
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node: [ '16', '18' ]
node: [ '18' ]

name: Node ${{ matrix.node }} tests

Expand All @@ -32,7 +32,7 @@ jobs:
run: yarn --frozen-lockfile

- name: Run Jest tests with coverage
run: yarn test:coverage -w 1
run: yarn test:coverage

- name: Run node server side tests
run: yarn test:serverside
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yarn run lint
yarn run format:check
yarn run test related --silent
1 change: 1 addition & 0 deletions .storybook/custom-styles.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@forward '../src/styles/uswds-theme';
@use 'uswds-core' as *;

// Add custom styles for storybook implementation
Expand Down
124 changes: 15 additions & 109 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,114 +1,20 @@
import type { StorybookConfig } from '@storybook/react-webpack5'

const path = require('path')

const uswdsIncludePaths = [
'./node_modules/@uswds',
'./node_modules/@uswds/uswds/packages',
]

const webpackConfig = (config) => {
config.resolve.alias.uswds = path.resolve(
__dirname,
'../node_modules/@uswds/uswds'
)

config.module.rules = config.module.rules.filter(
(rule) => rule.test && rule.test.toString() !== '/\\.css$/'
)
config.module.rules.push({
test: /\.(sa|sc|c)ss$/,
exclude: /\.module\.(sa|sc|c)ss$/i,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
includePaths: uswdsIncludePaths,
},
},
},
],
include: path.resolve(__dirname, '../'),
})

config.module.rules.push({
test: /\.module\.(sa|sc|c)ss$/i,
include: path.resolve(__dirname, '../src'),
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[path][name]__[local]--[hash:base64:5]',
},
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
includePaths: uswdsIncludePaths,
},
},
},
],
})

const fileLoaderRule = config.module.rules.find(
(rule) => rule.test && rule.test.test('.svg')
)
fileLoaderRule.exclude = /\.svg$/

config.module.rules.push({
test: /\.svg$/,
oneOf: [
{
issuer: /\.[jt]sx?$/,
resourceQuery: /svgr/,
use: [
{
loader: '@svgr/webpack',
options: {
icon: true,
},
},
],
},
{
type: 'asset',
},
],
})

return config
}

module.exports = {
stories: ['../src/**/*.stories.@(ts|tsx)'],
addons: ['@storybook/addon-essentials', '@storybook/addon-a11y'],
typescript: {
check: false,
checkOptions: {},
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
tsconfigPath: path.resolve(__dirname, '../tsconfig.json'),
},
},
webpackFinal: async (config) => {
return webpackConfig(config)
},
import type { StorybookConfig } from '@storybook/react-vite'

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-a11y',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/react-webpack5',
options: { strictMode: false },
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: 'tag',
},
staticDirs: ['./public'],
} as StorybookConfig
staticDirs: ['public'],
}
export default config
8 changes: 5 additions & 3 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"plugins": ["stylelint-scss", "stylelint-prettier"],
"plugins": ["stylelint-prettier"],
"rules": {
"at-rule-no-unknown": null,
"scss/at-rule-no-unknown": true,
"prettier/prettier": true,
"selector-class-pattern": ""
"selector-class-pattern": "",
"scss/function-no-unknown": null,
"at-rule-empty-line-before": null
},
"extends": ["stylelint-config-recommended", "stylelint-prettier/recommended", "stylelint-config-sass-guidelines", "stylelint-config-css-modules"],
"extends": ["stylelint-config-recommended", "stylelint-prettier/recommended", "stylelint-config-sass-guidelines", "stylelint-config-css-modules", "stylelint-config-standard-scss"]
}
Loading
Loading